id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
34,300
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity._getObjects
protected function _getObjects(array $labels = array()) { $objects = array(); foreach ($labels as $label) { $method = 'getActivity' . ucfirst($label); if (method_exists($this, $method)) { $object = $this->$method(); if ($object instanceof ComActivitiesActivityObjectInterface) { $objects[$label] = $object; } } } return $objects; }
php
protected function _getObjects(array $labels = array()) { $objects = array(); foreach ($labels as $label) { $method = 'getActivity' . ucfirst($label); if (method_exists($this, $method)) { $object = $this->$method(); if ($object instanceof ComActivitiesActivityObjectInterface) { $objects[$label] = $object; } } } return $objects; }
[ "protected", "function", "_getObjects", "(", "array", "$", "labels", "=", "array", "(", ")", ")", "{", "$", "objects", "=", "array", "(", ")", ";", "foreach", "(", "$", "labels", "as", "$", "label", ")", "{", "$", "method", "=", "'getActivity'", ".", "ucfirst", "(", "$", "label", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "object", "=", "$", "this", "->", "$", "method", "(", ")", ";", "if", "(", "$", "object", "instanceof", "ComActivitiesActivityObjectInterface", ")", "{", "$", "objects", "[", "$", "label", "]", "=", "$", "object", ";", "}", "}", "}", "return", "$", "objects", ";", "}" ]
Returns a list of activity objects provided their labels. @param array $labels The object labels. @return array An array containing ComActivitiesActivityObjectInterface objects.
[ "Returns", "a", "list", "of", "activity", "objects", "provided", "their", "labels", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L496-L515
34,301
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity._getObject
protected function _getObject($config = array()) { $config = new KObjectConfig($config); $config->append(array( 'attributes' => array(), 'translate' => true )); // Process all object sub-properties. foreach ($config as $key => $value) { if ($value instanceof KObjectConfig && $value->object === true) { $config->{$key} = $this->_getObject($value); } } if ($config->objectName && !$config->displayName) { $config->displayName = $config->objectName; } if (is_string($config->url)) { $config->url = $this->_getRoute($config->url); } // Make object non-linkable and set it as deleted if related entity is not found. if ($config->find && !$this->_findObject($config->find)) { $config->url = null; $config->deleted = true; } if ($config->image instanceof KObjectConfig) { if (is_string($config->image->url)) { $config->image->url = $this->_getRoute($config->image->url); } $config->image = $this->getObject('com:activities.activity.medialink', array('data' => $config->image)); } // Cleanup config. foreach (array('find', 'object') as $property) { unset($config->$property); } return $this->getObject('com:activities.activity.object', array('data' => $config)); }
php
protected function _getObject($config = array()) { $config = new KObjectConfig($config); $config->append(array( 'attributes' => array(), 'translate' => true )); // Process all object sub-properties. foreach ($config as $key => $value) { if ($value instanceof KObjectConfig && $value->object === true) { $config->{$key} = $this->_getObject($value); } } if ($config->objectName && !$config->displayName) { $config->displayName = $config->objectName; } if (is_string($config->url)) { $config->url = $this->_getRoute($config->url); } // Make object non-linkable and set it as deleted if related entity is not found. if ($config->find && !$this->_findObject($config->find)) { $config->url = null; $config->deleted = true; } if ($config->image instanceof KObjectConfig) { if (is_string($config->image->url)) { $config->image->url = $this->_getRoute($config->image->url); } $config->image = $this->getObject('com:activities.activity.medialink', array('data' => $config->image)); } // Cleanup config. foreach (array('find', 'object') as $property) { unset($config->$property); } return $this->getObject('com:activities.activity.object', array('data' => $config)); }
[ "protected", "function", "_getObject", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "KObjectConfig", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'attributes'", "=>", "array", "(", ")", ",", "'translate'", "=>", "true", ")", ")", ";", "// Process all object sub-properties.", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "KObjectConfig", "&&", "$", "value", "->", "object", "===", "true", ")", "{", "$", "config", "->", "{", "$", "key", "}", "=", "$", "this", "->", "_getObject", "(", "$", "value", ")", ";", "}", "}", "if", "(", "$", "config", "->", "objectName", "&&", "!", "$", "config", "->", "displayName", ")", "{", "$", "config", "->", "displayName", "=", "$", "config", "->", "objectName", ";", "}", "if", "(", "is_string", "(", "$", "config", "->", "url", ")", ")", "{", "$", "config", "->", "url", "=", "$", "this", "->", "_getRoute", "(", "$", "config", "->", "url", ")", ";", "}", "// Make object non-linkable and set it as deleted if related entity is not found.", "if", "(", "$", "config", "->", "find", "&&", "!", "$", "this", "->", "_findObject", "(", "$", "config", "->", "find", ")", ")", "{", "$", "config", "->", "url", "=", "null", ";", "$", "config", "->", "deleted", "=", "true", ";", "}", "if", "(", "$", "config", "->", "image", "instanceof", "KObjectConfig", ")", "{", "if", "(", "is_string", "(", "$", "config", "->", "image", "->", "url", ")", ")", "{", "$", "config", "->", "image", "->", "url", "=", "$", "this", "->", "_getRoute", "(", "$", "config", "->", "image", "->", "url", ")", ";", "}", "$", "config", "->", "image", "=", "$", "this", "->", "getObject", "(", "'com:activities.activity.medialink'", ",", "array", "(", "'data'", "=>", "$", "config", "->", "image", ")", ")", ";", "}", "// Cleanup config.", "foreach", "(", "array", "(", "'find'", ",", "'object'", ")", "as", "$", "property", ")", "{", "unset", "(", "$", "config", "->", "$", "property", ")", ";", "}", "return", "$", "this", "->", "getObject", "(", "'com:activities.activity.object'", ",", "array", "(", "'data'", "=>", "$", "config", ")", ")", ";", "}" ]
Get an activity object @param array $config An optional configuration array. The configuration array may contain activity object data as defined by ComActivitiesActivityObjectInterface. Additionally the following parameters may be passed in the configuration array: <br><br> - find (string): the label of an object to look for. If not found the object being created is set as deleted (with its deleted property set to true) and non-linkable (with its url property set to null). A call to a _findActivity{Label} method will be attempted for determining if an object with label as defined by {Label} exists. See {@link _findActivityActor()} as an example. <br><br> - translate (bool): translates displayName property if set to true. - object (bool): the configuration array may contain arrays which represent configurations for stacked activity objects. For them to be considered as object configurations, an object property with its value set to true must be included in the configuration array. @return ComActivitiesActivityObject The activity object.
[ "Get", "an", "activity", "object" ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L537-L584
34,302
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity._getConfig
protected function _getConfig($object) { $config = new KObjectConfig(); $method = '_' . strtolower($object) . 'Config'; // Call config setter if any. if (method_exists($this, $method)) { $this->$method($config); } return $config; }
php
protected function _getConfig($object) { $config = new KObjectConfig(); $method = '_' . strtolower($object) . 'Config'; // Call config setter if any. if (method_exists($this, $method)) { $this->$method($config); } return $config; }
[ "protected", "function", "_getConfig", "(", "$", "object", ")", "{", "$", "config", "=", "new", "KObjectConfig", "(", ")", ";", "$", "method", "=", "'_'", ".", "strtolower", "(", "$", "object", ")", ".", "'Config'", ";", "// Call config setter if any.", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "this", "->", "$", "method", "(", "$", "config", ")", ";", "}", "return", "$", "config", ";", "}" ]
Get an activity object config. @param string $object The object name. @return KObjectConfig
[ "Get", "an", "activity", "object", "config", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L592-L604
34,303
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity._actorConfig
protected function _actorConfig(KObjectConfig $config) { $objectName = $this->getAuthor()->getName(); $translate = false; if (!$this->created_by) { $objectName = 'Guest user'; $translate = true; } elseif (!$this->_findActivityActor()) { $objectName = 'Deleted user'; $translate = true; } $config->append(array( 'type' => array('objectName' => 'user', 'object' => true), 'id' => $this->created_by, 'url' => 'option=com_users&task=user.edit&id=' . $this->created_by, 'objectName' => $objectName, 'translate' => $translate, 'find' => 'actor' )); }
php
protected function _actorConfig(KObjectConfig $config) { $objectName = $this->getAuthor()->getName(); $translate = false; if (!$this->created_by) { $objectName = 'Guest user'; $translate = true; } elseif (!$this->_findActivityActor()) { $objectName = 'Deleted user'; $translate = true; } $config->append(array( 'type' => array('objectName' => 'user', 'object' => true), 'id' => $this->created_by, 'url' => 'option=com_users&task=user.edit&id=' . $this->created_by, 'objectName' => $objectName, 'translate' => $translate, 'find' => 'actor' )); }
[ "protected", "function", "_actorConfig", "(", "KObjectConfig", "$", "config", ")", "{", "$", "objectName", "=", "$", "this", "->", "getAuthor", "(", ")", "->", "getName", "(", ")", ";", "$", "translate", "=", "false", ";", "if", "(", "!", "$", "this", "->", "created_by", ")", "{", "$", "objectName", "=", "'Guest user'", ";", "$", "translate", "=", "true", ";", "}", "elseif", "(", "!", "$", "this", "->", "_findActivityActor", "(", ")", ")", "{", "$", "objectName", "=", "'Deleted user'", ";", "$", "translate", "=", "true", ";", "}", "$", "config", "->", "append", "(", "array", "(", "'type'", "=>", "array", "(", "'objectName'", "=>", "'user'", ",", "'object'", "=>", "true", ")", ",", "'id'", "=>", "$", "this", "->", "created_by", ",", "'url'", "=>", "'option=com_users&task=user.edit&id='", ".", "$", "this", "->", "created_by", ",", "'objectName'", "=>", "$", "objectName", ",", "'translate'", "=>", "$", "translate", ",", "'find'", "=>", "'actor'", ")", ")", ";", "}" ]
Set the actor config. @param KObjectConfig $config The actor config. @return KObjectConfig
[ "Set", "the", "actor", "config", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L612-L636
34,304
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity._objectConfig
protected function _objectConfig(KObjectConfig $config) { $config->append(array( 'id' => $this->row, 'objectName' => $this->title, 'type' => array('objectName' => $this->name, 'object' => true), 'url' => 'option=com_' . $this->package . '&view=' . $this->name . '&id=' . $this->row, 'attributes' => array('class' => array('object')), 'find' => 'object', 'translate' => false )); }
php
protected function _objectConfig(KObjectConfig $config) { $config->append(array( 'id' => $this->row, 'objectName' => $this->title, 'type' => array('objectName' => $this->name, 'object' => true), 'url' => 'option=com_' . $this->package . '&view=' . $this->name . '&id=' . $this->row, 'attributes' => array('class' => array('object')), 'find' => 'object', 'translate' => false )); }
[ "protected", "function", "_objectConfig", "(", "KObjectConfig", "$", "config", ")", "{", "$", "config", "->", "append", "(", "array", "(", "'id'", "=>", "$", "this", "->", "row", ",", "'objectName'", "=>", "$", "this", "->", "title", ",", "'type'", "=>", "array", "(", "'objectName'", "=>", "$", "this", "->", "name", ",", "'object'", "=>", "true", ")", ",", "'url'", "=>", "'option=com_'", ".", "$", "this", "->", "package", ".", "'&view='", ".", "$", "this", "->", "name", ".", "'&id='", ".", "$", "this", "->", "row", ",", "'attributes'", "=>", "array", "(", "'class'", "=>", "array", "(", "'object'", ")", ")", ",", "'find'", "=>", "'object'", ",", "'translate'", "=>", "false", ")", ")", ";", "}" ]
Set the object config. @param KObjectConfig $config The object config.
[ "Set", "the", "object", "config", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L643-L654
34,305
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity._findObject
protected function _findObject($label) { $result = false; $signature = null; $method = sprintf('_get%sSignature', ucfirst($label)); if (method_exists($this, $method)) { $signature = $this->$method(); } if (is_null($signature) || !isset(self::$_find_results[$signature])) { $method = '_findActivity' . ucfirst($label); if (method_exists($this, $method)) { $result = (bool) $this->$method(); } if ($signature) { self::$_find_results[$signature] = $result; } } else $result = self::$_find_results[$signature]; return $result; }
php
protected function _findObject($label) { $result = false; $signature = null; $method = sprintf('_get%sSignature', ucfirst($label)); if (method_exists($this, $method)) { $signature = $this->$method(); } if (is_null($signature) || !isset(self::$_find_results[$signature])) { $method = '_findActivity' . ucfirst($label); if (method_exists($this, $method)) { $result = (bool) $this->$method(); } if ($signature) { self::$_find_results[$signature] = $result; } } else $result = self::$_find_results[$signature]; return $result; }
[ "protected", "function", "_findObject", "(", "$", "label", ")", "{", "$", "result", "=", "false", ";", "$", "signature", "=", "null", ";", "$", "method", "=", "sprintf", "(", "'_get%sSignature'", ",", "ucfirst", "(", "$", "label", ")", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "signature", "=", "$", "this", "->", "$", "method", "(", ")", ";", "}", "if", "(", "is_null", "(", "$", "signature", ")", "||", "!", "isset", "(", "self", "::", "$", "_find_results", "[", "$", "signature", "]", ")", ")", "{", "$", "method", "=", "'_findActivity'", ".", "ucfirst", "(", "$", "label", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "result", "=", "(", "bool", ")", "$", "this", "->", "$", "method", "(", ")", ";", "}", "if", "(", "$", "signature", ")", "{", "self", "::", "$", "_find_results", "[", "$", "signature", "]", "=", "$", "result", ";", "}", "}", "else", "$", "result", "=", "self", "::", "$", "_find_results", "[", "$", "signature", "]", ";", "return", "$", "result", ";", "}" ]
Find an activity object. @param string $label The object label. @return bool True if found, false otherwise.
[ "Find", "an", "activity", "object", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L712-L738
34,306
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity._findActivityObject
protected function _findActivityObject() { $db = $this->getTable()->getAdapter(); $table = $this->_object_table; $column = $this->_object_column; $query = $this->getObject('lib:database.query.select'); $query->columns('COUNT(*)')->table($table)->where($column . ' = :value') ->bind(array('value' => $this->row)); // Need to catch exceptions here as table may not longer exist. try { $result = $db->select($query, KDatabase::FETCH_FIELD); } catch (Exception $e) { $result = 0; } return $result; }
php
protected function _findActivityObject() { $db = $this->getTable()->getAdapter(); $table = $this->_object_table; $column = $this->_object_column; $query = $this->getObject('lib:database.query.select'); $query->columns('COUNT(*)')->table($table)->where($column . ' = :value') ->bind(array('value' => $this->row)); // Need to catch exceptions here as table may not longer exist. try { $result = $db->select($query, KDatabase::FETCH_FIELD); } catch (Exception $e) { $result = 0; } return $result; }
[ "protected", "function", "_findActivityObject", "(", ")", "{", "$", "db", "=", "$", "this", "->", "getTable", "(", ")", "->", "getAdapter", "(", ")", ";", "$", "table", "=", "$", "this", "->", "_object_table", ";", "$", "column", "=", "$", "this", "->", "_object_column", ";", "$", "query", "=", "$", "this", "->", "getObject", "(", "'lib:database.query.select'", ")", ";", "$", "query", "->", "columns", "(", "'COUNT(*)'", ")", "->", "table", "(", "$", "table", ")", "->", "where", "(", "$", "column", ".", "' = :value'", ")", "->", "bind", "(", "array", "(", "'value'", "=>", "$", "this", "->", "row", ")", ")", ";", "// Need to catch exceptions here as table may not longer exist.", "try", "{", "$", "result", "=", "$", "db", "->", "select", "(", "$", "query", ",", "KDatabase", "::", "FETCH_FIELD", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "result", "=", "0", ";", "}", "return", "$", "result", ";", "}" ]
Finds the activity object. This method may be overridden for activities persisting objects on storage systems other than local database tables. @return boolean True if found, false otherwise.
[ "Finds", "the", "activity", "object", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L748-L766
34,307
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity._findActivityActor
protected function _findActivityActor() { $user = $this->getObject('user.provider')->fetch($this->created_by); return is_null($user) ? false : true; }
php
protected function _findActivityActor() { $user = $this->getObject('user.provider')->fetch($this->created_by); return is_null($user) ? false : true; }
[ "protected", "function", "_findActivityActor", "(", ")", "{", "$", "user", "=", "$", "this", "->", "getObject", "(", "'user.provider'", ")", "->", "fetch", "(", "$", "this", "->", "created_by", ")", ";", "return", "is_null", "(", "$", "user", ")", "?", "false", ":", "true", ";", "}" ]
Finds the activity actor. @return boolean True if found, false otherwise.
[ "Finds", "the", "activity", "actor", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L773-L778
34,308
aviat4ion/Query
src/QueryParser.php
QueryParser.parseJoin
public function parseJoin(string $sql): array { // Get sql clause components preg_match_all('`'.$this->matchPatterns['function'].'`', $sql, $this->matches['functions'], PREG_SET_ORDER); preg_match_all('`'.$this->matchPatterns['identifier'].'`', $sql, $this->matches['identifiers'], PREG_SET_ORDER); preg_match_all('`'.$this->matchPatterns['operator'].'`', $sql, $this->matches['operators'], PREG_SET_ORDER); // Get everything at once for ordering $fullPattern = '`'.$this->matchPatterns['function'].'+|'.$this->matchPatterns['identifier'].'|('.$this->matchPatterns['operator'].')+`i'; preg_match_all($fullPattern, $sql, $this->matches['combined'], PREG_SET_ORDER); // Go through the matches, and get the most relevant matches $this->matches = array_map([$this, 'filterArray'], $this->matches); return $this->matches; }
php
public function parseJoin(string $sql): array { // Get sql clause components preg_match_all('`'.$this->matchPatterns['function'].'`', $sql, $this->matches['functions'], PREG_SET_ORDER); preg_match_all('`'.$this->matchPatterns['identifier'].'`', $sql, $this->matches['identifiers'], PREG_SET_ORDER); preg_match_all('`'.$this->matchPatterns['operator'].'`', $sql, $this->matches['operators'], PREG_SET_ORDER); // Get everything at once for ordering $fullPattern = '`'.$this->matchPatterns['function'].'+|'.$this->matchPatterns['identifier'].'|('.$this->matchPatterns['operator'].')+`i'; preg_match_all($fullPattern, $sql, $this->matches['combined'], PREG_SET_ORDER); // Go through the matches, and get the most relevant matches $this->matches = array_map([$this, 'filterArray'], $this->matches); return $this->matches; }
[ "public", "function", "parseJoin", "(", "string", "$", "sql", ")", ":", "array", "{", "// Get sql clause components", "preg_match_all", "(", "'`'", ".", "$", "this", "->", "matchPatterns", "[", "'function'", "]", ".", "'`'", ",", "$", "sql", ",", "$", "this", "->", "matches", "[", "'functions'", "]", ",", "PREG_SET_ORDER", ")", ";", "preg_match_all", "(", "'`'", ".", "$", "this", "->", "matchPatterns", "[", "'identifier'", "]", ".", "'`'", ",", "$", "sql", ",", "$", "this", "->", "matches", "[", "'identifiers'", "]", ",", "PREG_SET_ORDER", ")", ";", "preg_match_all", "(", "'`'", ".", "$", "this", "->", "matchPatterns", "[", "'operator'", "]", ".", "'`'", ",", "$", "sql", ",", "$", "this", "->", "matches", "[", "'operators'", "]", ",", "PREG_SET_ORDER", ")", ";", "// Get everything at once for ordering", "$", "fullPattern", "=", "'`'", ".", "$", "this", "->", "matchPatterns", "[", "'function'", "]", ".", "'+|'", ".", "$", "this", "->", "matchPatterns", "[", "'identifier'", "]", ".", "'|('", ".", "$", "this", "->", "matchPatterns", "[", "'operator'", "]", ".", "')+`i'", ";", "preg_match_all", "(", "$", "fullPattern", ",", "$", "sql", ",", "$", "this", "->", "matches", "[", "'combined'", "]", ",", "PREG_SET_ORDER", ")", ";", "// Go through the matches, and get the most relevant matches", "$", "this", "->", "matches", "=", "array_map", "(", "[", "$", "this", ",", "'filterArray'", "]", ",", "$", "this", "->", "matches", ")", ";", "return", "$", "this", "->", "matches", ";", "}" ]
Parser method for setting the parse string @param string $sql @return array
[ "Parser", "method", "for", "setting", "the", "parse", "string" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryParser.php#L70-L85
34,309
aviat4ion/Query
src/QueryParser.php
QueryParser.compileJoin
public function compileJoin(string $condition): string { $parts = $this->parseJoin($condition); $count = count($parts['identifiers']); // Go through and quote the identifiers for($i=0; $i <= $count; $i++) { if (in_array($parts['combined'][$i], $parts['identifiers']) && ! is_numeric($parts['combined'][$i])) { $parts['combined'][$i] = $this->db->quoteIdent($parts['combined'][$i]); } } return implode('', $parts['combined']); }
php
public function compileJoin(string $condition): string { $parts = $this->parseJoin($condition); $count = count($parts['identifiers']); // Go through and quote the identifiers for($i=0; $i <= $count; $i++) { if (in_array($parts['combined'][$i], $parts['identifiers']) && ! is_numeric($parts['combined'][$i])) { $parts['combined'][$i] = $this->db->quoteIdent($parts['combined'][$i]); } } return implode('', $parts['combined']); }
[ "public", "function", "compileJoin", "(", "string", "$", "condition", ")", ":", "string", "{", "$", "parts", "=", "$", "this", "->", "parseJoin", "(", "$", "condition", ")", ";", "$", "count", "=", "count", "(", "$", "parts", "[", "'identifiers'", "]", ")", ";", "// Go through and quote the identifiers", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<=", "$", "count", ";", "$", "i", "++", ")", "{", "if", "(", "in_array", "(", "$", "parts", "[", "'combined'", "]", "[", "$", "i", "]", ",", "$", "parts", "[", "'identifiers'", "]", ")", "&&", "!", "is_numeric", "(", "$", "parts", "[", "'combined'", "]", "[", "$", "i", "]", ")", ")", "{", "$", "parts", "[", "'combined'", "]", "[", "$", "i", "]", "=", "$", "this", "->", "db", "->", "quoteIdent", "(", "$", "parts", "[", "'combined'", "]", "[", "$", "i", "]", ")", ";", "}", "}", "return", "implode", "(", "''", ",", "$", "parts", "[", "'combined'", "]", ")", ";", "}" ]
Compiles a join condition after parsing @param string $condition @return string
[ "Compiles", "a", "join", "condition", "after", "parsing" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryParser.php#L93-L108
34,310
aviat4ion/Query
src/QueryParser.php
QueryParser.filterArray
protected function filterArray(array $array): array { $newArray = []; foreach($array as $row) { $newArray[] = (is_array($row)) ? $row[0] : $row; } return $newArray; }
php
protected function filterArray(array $array): array { $newArray = []; foreach($array as $row) { $newArray[] = (is_array($row)) ? $row[0] : $row; } return $newArray; }
[ "protected", "function", "filterArray", "(", "array", "$", "array", ")", ":", "array", "{", "$", "newArray", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "row", ")", "{", "$", "newArray", "[", "]", "=", "(", "is_array", "(", "$", "row", ")", ")", "?", "$", "row", "[", "0", "]", ":", "$", "row", ";", "}", "return", "$", "newArray", ";", "}" ]
Returns a more useful match array @param array $array @return array
[ "Returns", "a", "more", "useful", "match", "array" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryParser.php#L116-L126
34,311
joomlatools/joomlatools-framework-activities
controller/behavior/purgeable.php
ComActivitiesControllerBehaviorPurgeable._actionPurge
protected function _actionPurge(KControllerContextInterface $context) { $model = $this->getModel(); $state = $model->getState(); $query = $this->getObject('lib:database.query.delete'); $query->table(array($model->getTable()->getName())); if ($state->end_date && $state->end_date != '0000-00-00') { $end_date = $this->getObject('lib:date', array('date' => $state->end_date)); $end = $end_date->format('Y-m-d'); $query->where('DATE(created_on) <= :end')->bind(array('end' => $end)); } if (!$this->getModel()->getTable()->getAdapter()->execute($query)) { throw new KControllerExceptionActionFailed('Delete Action Failed'); } else { $context->getResponse()->setStatus(KHttpResponse::NO_CONTENT); } }
php
protected function _actionPurge(KControllerContextInterface $context) { $model = $this->getModel(); $state = $model->getState(); $query = $this->getObject('lib:database.query.delete'); $query->table(array($model->getTable()->getName())); if ($state->end_date && $state->end_date != '0000-00-00') { $end_date = $this->getObject('lib:date', array('date' => $state->end_date)); $end = $end_date->format('Y-m-d'); $query->where('DATE(created_on) <= :end')->bind(array('end' => $end)); } if (!$this->getModel()->getTable()->getAdapter()->execute($query)) { throw new KControllerExceptionActionFailed('Delete Action Failed'); } else { $context->getResponse()->setStatus(KHttpResponse::NO_CONTENT); } }
[ "protected", "function", "_actionPurge", "(", "KControllerContextInterface", "$", "context", ")", "{", "$", "model", "=", "$", "this", "->", "getModel", "(", ")", ";", "$", "state", "=", "$", "model", "->", "getState", "(", ")", ";", "$", "query", "=", "$", "this", "->", "getObject", "(", "'lib:database.query.delete'", ")", ";", "$", "query", "->", "table", "(", "array", "(", "$", "model", "->", "getTable", "(", ")", "->", "getName", "(", ")", ")", ")", ";", "if", "(", "$", "state", "->", "end_date", "&&", "$", "state", "->", "end_date", "!=", "'0000-00-00'", ")", "{", "$", "end_date", "=", "$", "this", "->", "getObject", "(", "'lib:date'", ",", "array", "(", "'date'", "=>", "$", "state", "->", "end_date", ")", ")", ";", "$", "end", "=", "$", "end_date", "->", "format", "(", "'Y-m-d'", ")", ";", "$", "query", "->", "where", "(", "'DATE(created_on) <= :end'", ")", "->", "bind", "(", "array", "(", "'end'", "=>", "$", "end", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "getModel", "(", ")", "->", "getTable", "(", ")", "->", "getAdapter", "(", ")", "->", "execute", "(", "$", "query", ")", ")", "{", "throw", "new", "KControllerExceptionActionFailed", "(", "'Delete Action Failed'", ")", ";", "}", "else", "{", "$", "context", "->", "getResponse", "(", ")", "->", "setStatus", "(", "KHttpResponse", "::", "NO_CONTENT", ")", ";", "}", "}" ]
Purge action. Deletes activities given a date range. @param KControllerContextInterface $context A command context object. @throws KControllerExceptionActionFailed If the activities cannot be purged. @return KModelEntityInterface
[ "Purge", "action", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/controller/behavior/purgeable.php#L29-L50
34,312
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.select
public function select(string $fields): QueryBuilderInterface { // Split fields by comma $fieldsArray = explode(',', $fields); $fieldsArray = array_map('mb_trim', $fieldsArray); // Split on 'As' foreach ($fieldsArray as $key => $field) { if (stripos($field, 'as') !== FALSE) { $fieldsArray[$key] = preg_split('` as `i', $field); $fieldsArray[$key] = array_map('mb_trim', $fieldsArray[$key]); } } // Quote the identifiers $safeArray = $this->driver->quoteIdent($fieldsArray); unset($fieldsArray); // Join the strings back together for($i = 0, $c = count($safeArray); $i < $c; $i++) { if (\is_array($safeArray[$i])) { $safeArray[$i] = implode(' AS ', $safeArray[$i]); } } $this->state->appendSelectString(implode(', ', $safeArray)); return $this; }
php
public function select(string $fields): QueryBuilderInterface { // Split fields by comma $fieldsArray = explode(',', $fields); $fieldsArray = array_map('mb_trim', $fieldsArray); // Split on 'As' foreach ($fieldsArray as $key => $field) { if (stripos($field, 'as') !== FALSE) { $fieldsArray[$key] = preg_split('` as `i', $field); $fieldsArray[$key] = array_map('mb_trim', $fieldsArray[$key]); } } // Quote the identifiers $safeArray = $this->driver->quoteIdent($fieldsArray); unset($fieldsArray); // Join the strings back together for($i = 0, $c = count($safeArray); $i < $c; $i++) { if (\is_array($safeArray[$i])) { $safeArray[$i] = implode(' AS ', $safeArray[$i]); } } $this->state->appendSelectString(implode(', ', $safeArray)); return $this; }
[ "public", "function", "select", "(", "string", "$", "fields", ")", ":", "QueryBuilderInterface", "{", "// Split fields by comma", "$", "fieldsArray", "=", "explode", "(", "','", ",", "$", "fields", ")", ";", "$", "fieldsArray", "=", "array_map", "(", "'mb_trim'", ",", "$", "fieldsArray", ")", ";", "// Split on 'As'", "foreach", "(", "$", "fieldsArray", "as", "$", "key", "=>", "$", "field", ")", "{", "if", "(", "stripos", "(", "$", "field", ",", "'as'", ")", "!==", "FALSE", ")", "{", "$", "fieldsArray", "[", "$", "key", "]", "=", "preg_split", "(", "'` as `i'", ",", "$", "field", ")", ";", "$", "fieldsArray", "[", "$", "key", "]", "=", "array_map", "(", "'mb_trim'", ",", "$", "fieldsArray", "[", "$", "key", "]", ")", ";", "}", "}", "// Quote the identifiers", "$", "safeArray", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "fieldsArray", ")", ";", "unset", "(", "$", "fieldsArray", ")", ";", "// Join the strings back together", "for", "(", "$", "i", "=", "0", ",", "$", "c", "=", "count", "(", "$", "safeArray", ")", ";", "$", "i", "<", "$", "c", ";", "$", "i", "++", ")", "{", "if", "(", "\\", "is_array", "(", "$", "safeArray", "[", "$", "i", "]", ")", ")", "{", "$", "safeArray", "[", "$", "i", "]", "=", "implode", "(", "' AS '", ",", "$", "safeArray", "[", "$", "i", "]", ")", ";", "}", "}", "$", "this", "->", "state", "->", "appendSelectString", "(", "implode", "(", "', '", ",", "$", "safeArray", ")", ")", ";", "return", "$", "this", ";", "}" ]
Specifies rows to select in a query @param string $fields @return QueryBuilderInterface
[ "Specifies", "rows", "to", "select", "in", "a", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L121-L154
34,313
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.selectMax
public function selectMax(string $field, $as=FALSE): QueryBuilderInterface { // Create the select string $this->state->appendSelectString(' MAX'.$this->_select($field, $as)); return $this; }
php
public function selectMax(string $field, $as=FALSE): QueryBuilderInterface { // Create the select string $this->state->appendSelectString(' MAX'.$this->_select($field, $as)); return $this; }
[ "public", "function", "selectMax", "(", "string", "$", "field", ",", "$", "as", "=", "FALSE", ")", ":", "QueryBuilderInterface", "{", "// Create the select string", "$", "this", "->", "state", "->", "appendSelectString", "(", "' MAX'", ".", "$", "this", "->", "_select", "(", "$", "field", ",", "$", "as", ")", ")", ";", "return", "$", "this", ";", "}" ]
Selects the maximum value of a field from a query @param string $field @param string|bool $as @return QueryBuilderInterface
[ "Selects", "the", "maximum", "value", "of", "a", "field", "from", "a", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L163-L168
34,314
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.from
public function from(string $tblname): QueryBuilderInterface { // Split identifiers on spaces $identArray = explode(' ', \mb_trim($tblname)); $identArray = array_map('\\mb_trim', $identArray); // Quote the identifiers $identArray[0] = $this->driver->quoteTable($identArray[0]); $identArray = $this->driver->quoteIdent($identArray); // Paste it back together $this->state->setFromString(implode(' ', $identArray)); return $this; }
php
public function from(string $tblname): QueryBuilderInterface { // Split identifiers on spaces $identArray = explode(' ', \mb_trim($tblname)); $identArray = array_map('\\mb_trim', $identArray); // Quote the identifiers $identArray[0] = $this->driver->quoteTable($identArray[0]); $identArray = $this->driver->quoteIdent($identArray); // Paste it back together $this->state->setFromString(implode(' ', $identArray)); return $this; }
[ "public", "function", "from", "(", "string", "$", "tblname", ")", ":", "QueryBuilderInterface", "{", "// Split identifiers on spaces", "$", "identArray", "=", "explode", "(", "' '", ",", "\\", "mb_trim", "(", "$", "tblname", ")", ")", ";", "$", "identArray", "=", "array_map", "(", "'\\\\mb_trim'", ",", "$", "identArray", ")", ";", "// Quote the identifiers", "$", "identArray", "[", "0", "]", "=", "$", "this", "->", "driver", "->", "quoteTable", "(", "$", "identArray", "[", "0", "]", ")", ";", "$", "identArray", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "identArray", ")", ";", "// Paste it back together", "$", "this", "->", "state", "->", "setFromString", "(", "implode", "(", "' '", ",", "$", "identArray", ")", ")", ";", "return", "$", "this", ";", "}" ]
Specify the database table to select from @param string $tblname @return QueryBuilderInterface
[ "Specify", "the", "database", "table", "to", "select", "from" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L241-L255
34,315
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.like
public function like(string $field, $val, string $pos='both'): QueryBuilderInterface { return $this->_like($field, $val, $pos); }
php
public function like(string $field, $val, string $pos='both'): QueryBuilderInterface { return $this->_like($field, $val, $pos); }
[ "public", "function", "like", "(", "string", "$", "field", ",", "$", "val", ",", "string", "$", "pos", "=", "'both'", ")", ":", "QueryBuilderInterface", "{", "return", "$", "this", "->", "_like", "(", "$", "field", ",", "$", "val", ",", "$", "pos", ")", ";", "}" ]
Creates a Like clause in the sql statement @param string $field @param mixed $val @param string $pos @return QueryBuilderInterface
[ "Creates", "a", "Like", "clause", "in", "the", "sql", "statement" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L269-L272
34,316
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.orLike
public function orLike(string $field, $val, string $pos='both'): QueryBuilderInterface { return $this->_like($field, $val, $pos, 'LIKE', 'OR'); }
php
public function orLike(string $field, $val, string $pos='both'): QueryBuilderInterface { return $this->_like($field, $val, $pos, 'LIKE', 'OR'); }
[ "public", "function", "orLike", "(", "string", "$", "field", ",", "$", "val", ",", "string", "$", "pos", "=", "'both'", ")", ":", "QueryBuilderInterface", "{", "return", "$", "this", "->", "_like", "(", "$", "field", ",", "$", "val", ",", "$", "pos", ",", "'LIKE'", ",", "'OR'", ")", ";", "}" ]
Generates an OR Like clause @param string $field @param mixed $val @param string $pos @return QueryBuilderInterface
[ "Generates", "an", "OR", "Like", "clause" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L282-L285
34,317
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.notLike
public function notLike(string $field, $val, string $pos='both'): QueryBuilderInterface { return $this->_like($field, $val, $pos, 'NOT LIKE'); }
php
public function notLike(string $field, $val, string $pos='both'): QueryBuilderInterface { return $this->_like($field, $val, $pos, 'NOT LIKE'); }
[ "public", "function", "notLike", "(", "string", "$", "field", ",", "$", "val", ",", "string", "$", "pos", "=", "'both'", ")", ":", "QueryBuilderInterface", "{", "return", "$", "this", "->", "_like", "(", "$", "field", ",", "$", "val", ",", "$", "pos", ",", "'NOT LIKE'", ")", ";", "}" ]
Generates a NOT LIKE clause @param string $field @param mixed $val @param string $pos @return QueryBuilderInterface
[ "Generates", "a", "NOT", "LIKE", "clause" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L295-L298
34,318
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.orNotLike
public function orNotLike(string $field, $val, string $pos='both'): QueryBuilderInterface { return $this->_like($field, $val, $pos, 'NOT LIKE', 'OR'); }
php
public function orNotLike(string $field, $val, string $pos='both'): QueryBuilderInterface { return $this->_like($field, $val, $pos, 'NOT LIKE', 'OR'); }
[ "public", "function", "orNotLike", "(", "string", "$", "field", ",", "$", "val", ",", "string", "$", "pos", "=", "'both'", ")", ":", "QueryBuilderInterface", "{", "return", "$", "this", "->", "_like", "(", "$", "field", ",", "$", "val", ",", "$", "pos", ",", "'NOT LIKE'", ",", "'OR'", ")", ";", "}" ]
Generates a OR NOT LIKE clause @param string $field @param mixed $val @param string $pos @return QueryBuilderInterface
[ "Generates", "a", "OR", "NOT", "LIKE", "clause" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L308-L311
34,319
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.join
public function join(string $table, string $condition, string $type=''): QueryBuilderInterface { // Prefix and quote table name $table = explode(' ', mb_trim($table)); $table[0] = $this->driver->quoteTable($table[0]); $table = $this->driver->quoteIdent($table); $table = implode(' ', $table); // Parse out the join condition $parsedCondition = $this->parser->compileJoin($condition); $condition = $table . ' ON ' . $parsedCondition; $this->state->appendMap("\n" . strtoupper($type) . ' JOIN ', $condition, 'join'); return $this; }
php
public function join(string $table, string $condition, string $type=''): QueryBuilderInterface { // Prefix and quote table name $table = explode(' ', mb_trim($table)); $table[0] = $this->driver->quoteTable($table[0]); $table = $this->driver->quoteIdent($table); $table = implode(' ', $table); // Parse out the join condition $parsedCondition = $this->parser->compileJoin($condition); $condition = $table . ' ON ' . $parsedCondition; $this->state->appendMap("\n" . strtoupper($type) . ' JOIN ', $condition, 'join'); return $this; }
[ "public", "function", "join", "(", "string", "$", "table", ",", "string", "$", "condition", ",", "string", "$", "type", "=", "''", ")", ":", "QueryBuilderInterface", "{", "// Prefix and quote table name", "$", "table", "=", "explode", "(", "' '", ",", "mb_trim", "(", "$", "table", ")", ")", ";", "$", "table", "[", "0", "]", "=", "$", "this", "->", "driver", "->", "quoteTable", "(", "$", "table", "[", "0", "]", ")", ";", "$", "table", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "table", ")", ";", "$", "table", "=", "implode", "(", "' '", ",", "$", "table", ")", ";", "// Parse out the join condition", "$", "parsedCondition", "=", "$", "this", "->", "parser", "->", "compileJoin", "(", "$", "condition", ")", ";", "$", "condition", "=", "$", "table", ".", "' ON '", ".", "$", "parsedCondition", ";", "$", "this", "->", "state", "->", "appendMap", "(", "\"\\n\"", ".", "strtoupper", "(", "$", "type", ")", ".", "' JOIN '", ",", "$", "condition", ",", "'join'", ")", ";", "return", "$", "this", ";", "}" ]
Creates a join phrase in a compiled query @param string $table @param string $condition @param string $type @return QueryBuilderInterface
[ "Creates", "a", "join", "phrase", "in", "a", "compiled", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L471-L486
34,320
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.limit
public function limit(int $limit, $offset=FALSE): QueryBuilderInterface { $this->state->setLimit($limit); $this->state->setOffset($offset); return $this; }
php
public function limit(int $limit, $offset=FALSE): QueryBuilderInterface { $this->state->setLimit($limit); $this->state->setOffset($offset); return $this; }
[ "public", "function", "limit", "(", "int", "$", "limit", ",", "$", "offset", "=", "FALSE", ")", ":", "QueryBuilderInterface", "{", "$", "this", "->", "state", "->", "setLimit", "(", "$", "limit", ")", ";", "$", "this", "->", "state", "->", "setOffset", "(", "$", "offset", ")", ";", "return", "$", "this", ";", "}" ]
Set a limit on the current sql statement @param int $limit @param int|bool $offset @return QueryBuilderInterface
[ "Set", "a", "limit", "on", "the", "current", "sql", "statement" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L559-L565
34,321
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.groupStart
public function groupStart(): QueryBuilderInterface { $conj = empty($this->state->getQueryMap()) ? ' WHERE ' : ' '; $this->state->appendMap($conj, '(', 'group_start'); return $this; }
php
public function groupStart(): QueryBuilderInterface { $conj = empty($this->state->getQueryMap()) ? ' WHERE ' : ' '; $this->state->appendMap($conj, '(', 'group_start'); return $this; }
[ "public", "function", "groupStart", "(", ")", ":", "QueryBuilderInterface", "{", "$", "conj", "=", "empty", "(", "$", "this", "->", "state", "->", "getQueryMap", "(", ")", ")", "?", "' WHERE '", ":", "' '", ";", "$", "this", "->", "state", "->", "appendMap", "(", "$", "conj", ",", "'('", ",", "'group_start'", ")", ";", "return", "$", "this", ";", "}" ]
Adds a paren to the current query for query grouping @return QueryBuilderInterface
[ "Adds", "a", "paren", "to", "the", "current", "query", "for", "query", "grouping" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L576-L583
34,322
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.notGroupStart
public function notGroupStart(): QueryBuilderInterface { $conj = empty($this->state->getQueryMap()) ? ' WHERE ' : ' AND '; $this->state->appendMap($conj, ' NOT (', 'group_start'); return $this; }
php
public function notGroupStart(): QueryBuilderInterface { $conj = empty($this->state->getQueryMap()) ? ' WHERE ' : ' AND '; $this->state->appendMap($conj, ' NOT (', 'group_start'); return $this; }
[ "public", "function", "notGroupStart", "(", ")", ":", "QueryBuilderInterface", "{", "$", "conj", "=", "empty", "(", "$", "this", "->", "state", "->", "getQueryMap", "(", ")", ")", "?", "' WHERE '", ":", "' AND '", ";", "$", "this", "->", "state", "->", "appendMap", "(", "$", "conj", ",", "' NOT ('", ",", "'group_start'", ")", ";", "return", "$", "this", ";", "}" ]
Adds a paren to the current query for query grouping, prefixed with 'NOT' @return QueryBuilderInterface
[ "Adds", "a", "paren", "to", "the", "current", "query", "for", "query", "grouping", "prefixed", "with", "NOT" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L591-L598
34,323
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.countAll
public function countAll(string $table): int { $sql = 'SELECT * FROM '.$this->driver->quoteTable($table); $res = $this->driver->query($sql); return (int) count($res->fetchAll()); }
php
public function countAll(string $table): int { $sql = 'SELECT * FROM '.$this->driver->quoteTable($table); $res = $this->driver->query($sql); return (int) count($res->fetchAll()); }
[ "public", "function", "countAll", "(", "string", "$", "table", ")", ":", "int", "{", "$", "sql", "=", "'SELECT * FROM '", ".", "$", "this", "->", "driver", "->", "quoteTable", "(", "$", "table", ")", ";", "$", "res", "=", "$", "this", "->", "driver", "->", "query", "(", "$", "sql", ")", ";", "return", "(", "int", ")", "count", "(", "$", "res", "->", "fetchAll", "(", ")", ")", ";", "}" ]
Retrieve the number of rows in the selected table @param string $table @return int
[ "Retrieve", "the", "number", "of", "rows", "in", "the", "selected", "table" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L692-L697
34,324
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.insert
public function insert(string $table, $data=[]): ?PDOStatement { if ( ! empty($data)) { $this->set($data); } return $this->_run('insert', $table); }
php
public function insert(string $table, $data=[]): ?PDOStatement { if ( ! empty($data)) { $this->set($data); } return $this->_run('insert', $table); }
[ "public", "function", "insert", "(", "string", "$", "table", ",", "$", "data", "=", "[", "]", ")", ":", "?", "PDOStatement", "{", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "$", "this", "->", "set", "(", "$", "data", ")", ";", "}", "return", "$", "this", "->", "_run", "(", "'insert'", ",", "$", "table", ")", ";", "}" ]
Creates an insert clause, and executes it @param string $table @param mixed $data @return PDOStatement
[ "Creates", "an", "insert", "clause", "and", "executes", "it" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L728-L736
34,325
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.insertBatch
public function insertBatch(string $table, $data=[]): ?PDOStatement { // Get the generated values and sql string [$sql, $data] = $this->driver->insertBatch($table, $data); return $sql !== NULL ? $this->_run('', $table, $sql, $data) : NULL; }
php
public function insertBatch(string $table, $data=[]): ?PDOStatement { // Get the generated values and sql string [$sql, $data] = $this->driver->insertBatch($table, $data); return $sql !== NULL ? $this->_run('', $table, $sql, $data) : NULL; }
[ "public", "function", "insertBatch", "(", "string", "$", "table", ",", "$", "data", "=", "[", "]", ")", ":", "?", "PDOStatement", "{", "// Get the generated values and sql string", "[", "$", "sql", ",", "$", "data", "]", "=", "$", "this", "->", "driver", "->", "insertBatch", "(", "$", "table", ",", "$", "data", ")", ";", "return", "$", "sql", "!==", "NULL", "?", "$", "this", "->", "_run", "(", "''", ",", "$", "table", ",", "$", "sql", ",", "$", "data", ")", ":", "NULL", ";", "}" ]
Creates and executes a batch insertion query @param string $table @param array $data @return PDOStatement
[ "Creates", "and", "executes", "a", "batch", "insertion", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L745-L753
34,326
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.updateBatch
public function updateBatch(string $table, $data, $where): ?PDOStatement { // Get the generated values and sql string list($sql, $data) = $this->driver->updateBatch($table, $data, $where); return $sql !== NULL ? $this->_run('', $table, $sql, $data) : NULL; }
php
public function updateBatch(string $table, $data, $where): ?PDOStatement { // Get the generated values and sql string list($sql, $data) = $this->driver->updateBatch($table, $data, $where); return $sql !== NULL ? $this->_run('', $table, $sql, $data) : NULL; }
[ "public", "function", "updateBatch", "(", "string", "$", "table", ",", "$", "data", ",", "$", "where", ")", ":", "?", "PDOStatement", "{", "// Get the generated values and sql string", "list", "(", "$", "sql", ",", "$", "data", ")", "=", "$", "this", "->", "driver", "->", "updateBatch", "(", "$", "table", ",", "$", "data", ",", "$", "where", ")", ";", "return", "$", "sql", "!==", "NULL", "?", "$", "this", "->", "_run", "(", "''", ",", "$", "table", ",", "$", "sql", ",", "$", "data", ")", ":", "NULL", ";", "}" ]
Creates a batch update, and executes it. Returns the number of affected rows @param string $table @param array|object $data @param string $where @return PDOStatement|null
[ "Creates", "a", "batch", "update", "and", "executes", "it", ".", "Returns", "the", "number", "of", "affected", "rows" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L781-L789
34,327
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.delete
public function delete(string $table, $where=''): ?PDOStatement { // Set the where clause if ( ! empty($where)) { $this->where($where); } return $this->_run('delete', $table); }
php
public function delete(string $table, $where=''): ?PDOStatement { // Set the where clause if ( ! empty($where)) { $this->where($where); } return $this->_run('delete', $table); }
[ "public", "function", "delete", "(", "string", "$", "table", ",", "$", "where", "=", "''", ")", ":", "?", "PDOStatement", "{", "// Set the where clause", "if", "(", "!", "empty", "(", "$", "where", ")", ")", "{", "$", "this", "->", "where", "(", "$", "where", ")", ";", "}", "return", "$", "this", "->", "_run", "(", "'delete'", ",", "$", "table", ")", ";", "}" ]
Deletes data from a table @param string $table @param mixed $where @return PDOStatement
[ "Deletes", "data", "from", "a", "table" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L815-L824
34,328
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.getCompiledSelect
public function getCompiledSelect(string $table='', bool $reset=TRUE): string { // Set the table if ( ! empty($table)) { $this->from($table); } return $this->_getCompile('select', $table, $reset); }
php
public function getCompiledSelect(string $table='', bool $reset=TRUE): string { // Set the table if ( ! empty($table)) { $this->from($table); } return $this->_getCompile('select', $table, $reset); }
[ "public", "function", "getCompiledSelect", "(", "string", "$", "table", "=", "''", ",", "bool", "$", "reset", "=", "TRUE", ")", ":", "string", "{", "// Set the table", "if", "(", "!", "empty", "(", "$", "table", ")", ")", "{", "$", "this", "->", "from", "(", "$", "table", ")", ";", "}", "return", "$", "this", "->", "_getCompile", "(", "'select'", ",", "$", "table", ",", "$", "reset", ")", ";", "}" ]
Returns the generated 'select' sql query @param string $table @param bool $reset @return string
[ "Returns", "the", "generated", "select", "sql", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L837-L846
34,329
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.getCompiledInsert
public function getCompiledInsert(string $table, bool $reset=TRUE): string { return $this->_getCompile('insert', $table, $reset); }
php
public function getCompiledInsert(string $table, bool $reset=TRUE): string { return $this->_getCompile('insert', $table, $reset); }
[ "public", "function", "getCompiledInsert", "(", "string", "$", "table", ",", "bool", "$", "reset", "=", "TRUE", ")", ":", "string", "{", "return", "$", "this", "->", "_getCompile", "(", "'insert'", ",", "$", "table", ",", "$", "reset", ")", ";", "}" ]
Returns the generated 'insert' sql query @param string $table @param bool $reset @return string
[ "Returns", "the", "generated", "insert", "sql", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L855-L858
34,330
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.getCompiledUpdate
public function getCompiledUpdate(string $table='', bool $reset=TRUE): string { return $this->_getCompile('update', $table, $reset); }
php
public function getCompiledUpdate(string $table='', bool $reset=TRUE): string { return $this->_getCompile('update', $table, $reset); }
[ "public", "function", "getCompiledUpdate", "(", "string", "$", "table", "=", "''", ",", "bool", "$", "reset", "=", "TRUE", ")", ":", "string", "{", "return", "$", "this", "->", "_getCompile", "(", "'update'", ",", "$", "table", ",", "$", "reset", ")", ";", "}" ]
Returns the generated 'update' sql query @param string $table @param bool $reset @return string
[ "Returns", "the", "generated", "update", "sql", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L867-L870
34,331
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder.getCompiledDelete
public function getCompiledDelete(string $table='', bool $reset=TRUE): string { return $this->_getCompile('delete', $table, $reset); }
php
public function getCompiledDelete(string $table='', bool $reset=TRUE): string { return $this->_getCompile('delete', $table, $reset); }
[ "public", "function", "getCompiledDelete", "(", "string", "$", "table", "=", "''", ",", "bool", "$", "reset", "=", "TRUE", ")", ":", "string", "{", "return", "$", "this", "->", "_getCompile", "(", "'delete'", ",", "$", "table", ",", "$", "reset", ")", ";", "}" ]
Returns the generated 'delete' sql query @param string $table @param bool $reset @return string
[ "Returns", "the", "generated", "delete", "sql", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L879-L882
34,332
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._select
protected function _select(string $field, $as = FALSE): string { // Escape the identifiers $field = $this->driver->quoteIdent($field); if ( ! \is_string($as)) { return $field; } $as = $this->driver->quoteIdent($as); return "({$field}) AS {$as} "; }
php
protected function _select(string $field, $as = FALSE): string { // Escape the identifiers $field = $this->driver->quoteIdent($field); if ( ! \is_string($as)) { return $field; } $as = $this->driver->quoteIdent($as); return "({$field}) AS {$as} "; }
[ "protected", "function", "_select", "(", "string", "$", "field", ",", "$", "as", "=", "FALSE", ")", ":", "string", "{", "// Escape the identifiers", "$", "field", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "field", ")", ";", "if", "(", "!", "\\", "is_string", "(", "$", "as", ")", ")", "{", "return", "$", "field", ";", "}", "$", "as", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "as", ")", ";", "return", "\"({$field}) AS {$as} \"", ";", "}" ]
Method to simplify select_ methods @param string $field @param string|bool $as @return string
[ "Method", "to", "simplify", "select_", "methods" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L906-L918
34,333
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._getCompile
protected function _getCompile(string $type, string $table, bool $reset): string { $sql = $this->_compile($type, $table); // Reset the query builder for the next query if ($reset) { $this->resetQuery(); } return $sql; }
php
protected function _getCompile(string $type, string $table, bool $reset): string { $sql = $this->_compile($type, $table); // Reset the query builder for the next query if ($reset) { $this->resetQuery(); } return $sql; }
[ "protected", "function", "_getCompile", "(", "string", "$", "type", ",", "string", "$", "table", ",", "bool", "$", "reset", ")", ":", "string", "{", "$", "sql", "=", "$", "this", "->", "_compile", "(", "$", "type", ",", "$", "table", ")", ";", "// Reset the query builder for the next query", "if", "(", "$", "reset", ")", "{", "$", "this", "->", "resetQuery", "(", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Helper function for returning sql strings @param string $type @param string $table @param bool $reset @return string
[ "Helper", "function", "for", "returning", "sql", "strings" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L928-L939
34,334
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._like
protected function _like(string $field, $val, string $pos, string $like='LIKE', string $conj='AND'): self { $field = $this->driver->quoteIdent($field); // Add the like string into the order map $like = $field. " {$like} ?"; if ($pos === 'before') { $val = "%{$val}"; } elseif ($pos === 'after') { $val = "{$val}%"; } else { $val = "%{$val}%"; } $conj = empty($this->state->getQueryMap()) ? ' WHERE ' : " {$conj} "; $this->state->appendMap($conj, $like, 'like'); // Add to the values array $this->state->appendWhereValues($val); return $this; }
php
protected function _like(string $field, $val, string $pos, string $like='LIKE', string $conj='AND'): self { $field = $this->driver->quoteIdent($field); // Add the like string into the order map $like = $field. " {$like} ?"; if ($pos === 'before') { $val = "%{$val}"; } elseif ($pos === 'after') { $val = "{$val}%"; } else { $val = "%{$val}%"; } $conj = empty($this->state->getQueryMap()) ? ' WHERE ' : " {$conj} "; $this->state->appendMap($conj, $like, 'like'); // Add to the values array $this->state->appendWhereValues($val); return $this; }
[ "protected", "function", "_like", "(", "string", "$", "field", ",", "$", "val", ",", "string", "$", "pos", ",", "string", "$", "like", "=", "'LIKE'", ",", "string", "$", "conj", "=", "'AND'", ")", ":", "self", "{", "$", "field", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "field", ")", ";", "// Add the like string into the order map", "$", "like", "=", "$", "field", ".", "\" {$like} ?\"", ";", "if", "(", "$", "pos", "===", "'before'", ")", "{", "$", "val", "=", "\"%{$val}\"", ";", "}", "elseif", "(", "$", "pos", "===", "'after'", ")", "{", "$", "val", "=", "\"{$val}%\"", ";", "}", "else", "{", "$", "val", "=", "\"%{$val}%\"", ";", "}", "$", "conj", "=", "empty", "(", "$", "this", "->", "state", "->", "getQueryMap", "(", ")", ")", "?", "' WHERE '", ":", "\" {$conj} \"", ";", "$", "this", "->", "state", "->", "appendMap", "(", "$", "conj", ",", "$", "like", ",", "'like'", ")", ";", "// Add to the values array", "$", "this", "->", "state", "->", "appendWhereValues", "(", "$", "val", ")", ";", "return", "$", "this", ";", "}" ]
Simplify 'like' methods @param string $field @param mixed $val @param string $pos @param string $like @param string $conj @return self
[ "Simplify", "like", "methods" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L951-L978
34,335
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._having
protected function _having($key, $values=[], string $conj='AND'): self { $where = $this->_where($key, $values); // Create key/value placeholders foreach($where as $f => $val) { // Split each key by spaces, in case there // is an operator such as >, <, !=, etc. $fArray = explode(' ', trim($f)); $item = $this->driver->quoteIdent($fArray[0]); // Simple key value, or an operator $item .= (count($fArray) === 1) ? '=?' : " {$fArray[1]} ?"; // Put in the having map $this->state->appendHavingMap([ 'conjunction' => empty($this->state->getHavingMap()) ? ' HAVING ' : " {$conj} ", 'string' => $item ]); } return $this; }
php
protected function _having($key, $values=[], string $conj='AND'): self { $where = $this->_where($key, $values); // Create key/value placeholders foreach($where as $f => $val) { // Split each key by spaces, in case there // is an operator such as >, <, !=, etc. $fArray = explode(' ', trim($f)); $item = $this->driver->quoteIdent($fArray[0]); // Simple key value, or an operator $item .= (count($fArray) === 1) ? '=?' : " {$fArray[1]} ?"; // Put in the having map $this->state->appendHavingMap([ 'conjunction' => empty($this->state->getHavingMap()) ? ' HAVING ' : " {$conj} ", 'string' => $item ]); } return $this; }
[ "protected", "function", "_having", "(", "$", "key", ",", "$", "values", "=", "[", "]", ",", "string", "$", "conj", "=", "'AND'", ")", ":", "self", "{", "$", "where", "=", "$", "this", "->", "_where", "(", "$", "key", ",", "$", "values", ")", ";", "// Create key/value placeholders", "foreach", "(", "$", "where", "as", "$", "f", "=>", "$", "val", ")", "{", "// Split each key by spaces, in case there", "// is an operator such as >, <, !=, etc.", "$", "fArray", "=", "explode", "(", "' '", ",", "trim", "(", "$", "f", ")", ")", ";", "$", "item", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "fArray", "[", "0", "]", ")", ";", "// Simple key value, or an operator", "$", "item", ".=", "(", "count", "(", "$", "fArray", ")", "===", "1", ")", "?", "'=?'", ":", "\" {$fArray[1]} ?\"", ";", "// Put in the having map", "$", "this", "->", "state", "->", "appendHavingMap", "(", "[", "'conjunction'", "=>", "empty", "(", "$", "this", "->", "state", "->", "getHavingMap", "(", ")", ")", "?", "' HAVING '", ":", "\" {$conj} \"", ",", "'string'", "=>", "$", "item", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Simplify building having clauses @param mixed $key @param mixed $values @param string $conj @return self
[ "Simplify", "building", "having", "clauses" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L988-L1014
34,336
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._whereString
protected function _whereString($key, $values=[], string $defaultConj='AND'): self { // Create key/value placeholders foreach($this->_where($key, $values) as $f => $val) { $queryMap = $this->state->getQueryMap(); // Split each key by spaces, in case there // is an operator such as >, <, !=, etc. $fArray = explode(' ', trim($f)); $item = $this->driver->quoteIdent($fArray[0]); // Simple key value, or an operator $item .= (count($fArray) === 1) ? '=?' : " {$fArray[1]} ?"; $lastItem = end($queryMap); // Determine the correct conjunction $conjunctionList = array_column($queryMap, 'conjunction'); if (empty($queryMap) || ( ! \regexInArray($conjunctionList, "/^ ?\n?WHERE/i"))) { $conj = "\nWHERE "; } elseif ($lastItem['type'] === 'group_start') { $conj = ''; } else { $conj = " {$defaultConj} "; } $this->state->appendMap($conj, $item, 'where'); } return $this; }
php
protected function _whereString($key, $values=[], string $defaultConj='AND'): self { // Create key/value placeholders foreach($this->_where($key, $values) as $f => $val) { $queryMap = $this->state->getQueryMap(); // Split each key by spaces, in case there // is an operator such as >, <, !=, etc. $fArray = explode(' ', trim($f)); $item = $this->driver->quoteIdent($fArray[0]); // Simple key value, or an operator $item .= (count($fArray) === 1) ? '=?' : " {$fArray[1]} ?"; $lastItem = end($queryMap); // Determine the correct conjunction $conjunctionList = array_column($queryMap, 'conjunction'); if (empty($queryMap) || ( ! \regexInArray($conjunctionList, "/^ ?\n?WHERE/i"))) { $conj = "\nWHERE "; } elseif ($lastItem['type'] === 'group_start') { $conj = ''; } else { $conj = " {$defaultConj} "; } $this->state->appendMap($conj, $item, 'where'); } return $this; }
[ "protected", "function", "_whereString", "(", "$", "key", ",", "$", "values", "=", "[", "]", ",", "string", "$", "defaultConj", "=", "'AND'", ")", ":", "self", "{", "// Create key/value placeholders", "foreach", "(", "$", "this", "->", "_where", "(", "$", "key", ",", "$", "values", ")", "as", "$", "f", "=>", "$", "val", ")", "{", "$", "queryMap", "=", "$", "this", "->", "state", "->", "getQueryMap", "(", ")", ";", "// Split each key by spaces, in case there", "// is an operator such as >, <, !=, etc.", "$", "fArray", "=", "explode", "(", "' '", ",", "trim", "(", "$", "f", ")", ")", ";", "$", "item", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "fArray", "[", "0", "]", ")", ";", "// Simple key value, or an operator", "$", "item", ".=", "(", "count", "(", "$", "fArray", ")", "===", "1", ")", "?", "'=?'", ":", "\" {$fArray[1]} ?\"", ";", "$", "lastItem", "=", "end", "(", "$", "queryMap", ")", ";", "// Determine the correct conjunction", "$", "conjunctionList", "=", "array_column", "(", "$", "queryMap", ",", "'conjunction'", ")", ";", "if", "(", "empty", "(", "$", "queryMap", ")", "||", "(", "!", "\\", "regexInArray", "(", "$", "conjunctionList", ",", "\"/^ ?\\n?WHERE/i\"", ")", ")", ")", "{", "$", "conj", "=", "\"\\nWHERE \"", ";", "}", "elseif", "(", "$", "lastItem", "[", "'type'", "]", "===", "'group_start'", ")", "{", "$", "conj", "=", "''", ";", "}", "else", "{", "$", "conj", "=", "\" {$defaultConj} \"", ";", "}", "$", "this", "->", "state", "->", "appendMap", "(", "$", "conj", ",", "$", "item", ",", "'where'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Simplify generating where string @param mixed $key @param mixed $values @param string $defaultConj @return self
[ "Simplify", "generating", "where", "string" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L1054-L1090
34,337
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._whereIn
protected function _whereIn($key, $val=[], string $in='IN', string $conj='AND'): self { $key = $this->driver->quoteIdent($key); $params = array_fill(0, count($val), '?'); $this->state->appendWhereValues($val); $conjunction = empty($this->state->getQueryMap()) ? ' WHERE ' : " {$conj} "; $str = $key . " {$in} (".implode(',', $params).') '; $this->state->appendMap($conjunction, $str, 'where_in'); return $this; }
php
protected function _whereIn($key, $val=[], string $in='IN', string $conj='AND'): self { $key = $this->driver->quoteIdent($key); $params = array_fill(0, count($val), '?'); $this->state->appendWhereValues($val); $conjunction = empty($this->state->getQueryMap()) ? ' WHERE ' : " {$conj} "; $str = $key . " {$in} (".implode(',', $params).') '; $this->state->appendMap($conjunction, $str, 'where_in'); return $this; }
[ "protected", "function", "_whereIn", "(", "$", "key", ",", "$", "val", "=", "[", "]", ",", "string", "$", "in", "=", "'IN'", ",", "string", "$", "conj", "=", "'AND'", ")", ":", "self", "{", "$", "key", "=", "$", "this", "->", "driver", "->", "quoteIdent", "(", "$", "key", ")", ";", "$", "params", "=", "array_fill", "(", "0", ",", "count", "(", "$", "val", ")", ",", "'?'", ")", ";", "$", "this", "->", "state", "->", "appendWhereValues", "(", "$", "val", ")", ";", "$", "conjunction", "=", "empty", "(", "$", "this", "->", "state", "->", "getQueryMap", "(", ")", ")", "?", "' WHERE '", ":", "\" {$conj} \"", ";", "$", "str", "=", "$", "key", ".", "\" {$in} (\"", ".", "implode", "(", "','", ",", "$", "params", ")", ".", "') '", ";", "$", "this", "->", "state", "->", "appendMap", "(", "$", "conjunction", ",", "$", "str", ",", "'where_in'", ")", ";", "return", "$", "this", ";", "}" ]
Simplify where_in methods @param mixed $key @param mixed $val @param string $in - The (not) in fragment @param string $conj - The where in conjunction @return self
[ "Simplify", "where_in", "methods" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L1101-L1113
34,338
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._run
protected function _run(string $type, string $table, string $sql=NULL, array $vals=NULL, bool $reset=TRUE): PDOStatement { if ($sql === NULL) { $sql = $this->_compile($type, $table); } if ($vals === NULL) { $vals = array_merge($this->state->getValues(), $this->state->getWhereValues()); } $startTime = microtime(TRUE); $res = empty($vals) ? $this->driver->query($sql) : $this->driver->prepareExecute($sql, $vals); $endTime = microtime(TRUE); $totalTime = number_format($endTime - $startTime, 5); // Add this query to the list of executed queries $this->_appendQuery($vals, $sql, (int) $totalTime); // Reset class state for next query if ($reset) { $this->resetQuery(); } return $res; }
php
protected function _run(string $type, string $table, string $sql=NULL, array $vals=NULL, bool $reset=TRUE): PDOStatement { if ($sql === NULL) { $sql = $this->_compile($type, $table); } if ($vals === NULL) { $vals = array_merge($this->state->getValues(), $this->state->getWhereValues()); } $startTime = microtime(TRUE); $res = empty($vals) ? $this->driver->query($sql) : $this->driver->prepareExecute($sql, $vals); $endTime = microtime(TRUE); $totalTime = number_format($endTime - $startTime, 5); // Add this query to the list of executed queries $this->_appendQuery($vals, $sql, (int) $totalTime); // Reset class state for next query if ($reset) { $this->resetQuery(); } return $res; }
[ "protected", "function", "_run", "(", "string", "$", "type", ",", "string", "$", "table", ",", "string", "$", "sql", "=", "NULL", ",", "array", "$", "vals", "=", "NULL", ",", "bool", "$", "reset", "=", "TRUE", ")", ":", "PDOStatement", "{", "if", "(", "$", "sql", "===", "NULL", ")", "{", "$", "sql", "=", "$", "this", "->", "_compile", "(", "$", "type", ",", "$", "table", ")", ";", "}", "if", "(", "$", "vals", "===", "NULL", ")", "{", "$", "vals", "=", "array_merge", "(", "$", "this", "->", "state", "->", "getValues", "(", ")", ",", "$", "this", "->", "state", "->", "getWhereValues", "(", ")", ")", ";", "}", "$", "startTime", "=", "microtime", "(", "TRUE", ")", ";", "$", "res", "=", "empty", "(", "$", "vals", ")", "?", "$", "this", "->", "driver", "->", "query", "(", "$", "sql", ")", ":", "$", "this", "->", "driver", "->", "prepareExecute", "(", "$", "sql", ",", "$", "vals", ")", ";", "$", "endTime", "=", "microtime", "(", "TRUE", ")", ";", "$", "totalTime", "=", "number_format", "(", "$", "endTime", "-", "$", "startTime", ",", "5", ")", ";", "// Add this query to the list of executed queries", "$", "this", "->", "_appendQuery", "(", "$", "vals", ",", "$", "sql", ",", "(", "int", ")", "$", "totalTime", ")", ";", "// Reset class state for next query", "if", "(", "$", "reset", ")", "{", "$", "this", "->", "resetQuery", "(", ")", ";", "}", "return", "$", "res", ";", "}" ]
Executes the compiled query @param string $type @param string $table @param string $sql @param array|null $vals @param boolean $reset @return PDOStatement
[ "Executes", "the", "compiled", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L1125-L1156
34,339
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._appendQuery
protected function _appendQuery(array $vals = NULL, string $sql, int $totalTime) { $evals = \is_array($vals) ? $vals : []; $esql = str_replace('?', "%s", $sql); // Quote string values foreach($evals as &$v) { $v = ( ! is_numeric($v)) ? htmlentities($this->driver->quote($v), ENT_NOQUOTES, 'utf-8') : $v; } // Add the query onto the array of values to pass // as arguments to sprintf array_unshift($evals, $esql); // Add the interpreted query to the list of executed queries $this->queries[] = [ 'time' => $totalTime, 'sql' => sprintf(...$evals) ]; $this->queries['total_time'] += $totalTime; // Set the last query to get rowcounts properly $this->driver->setLastQuery($sql); }
php
protected function _appendQuery(array $vals = NULL, string $sql, int $totalTime) { $evals = \is_array($vals) ? $vals : []; $esql = str_replace('?', "%s", $sql); // Quote string values foreach($evals as &$v) { $v = ( ! is_numeric($v)) ? htmlentities($this->driver->quote($v), ENT_NOQUOTES, 'utf-8') : $v; } // Add the query onto the array of values to pass // as arguments to sprintf array_unshift($evals, $esql); // Add the interpreted query to the list of executed queries $this->queries[] = [ 'time' => $totalTime, 'sql' => sprintf(...$evals) ]; $this->queries['total_time'] += $totalTime; // Set the last query to get rowcounts properly $this->driver->setLastQuery($sql); }
[ "protected", "function", "_appendQuery", "(", "array", "$", "vals", "=", "NULL", ",", "string", "$", "sql", ",", "int", "$", "totalTime", ")", "{", "$", "evals", "=", "\\", "is_array", "(", "$", "vals", ")", "?", "$", "vals", ":", "[", "]", ";", "$", "esql", "=", "str_replace", "(", "'?'", ",", "\"%s\"", ",", "$", "sql", ")", ";", "// Quote string values", "foreach", "(", "$", "evals", "as", "&", "$", "v", ")", "{", "$", "v", "=", "(", "!", "is_numeric", "(", "$", "v", ")", ")", "?", "htmlentities", "(", "$", "this", "->", "driver", "->", "quote", "(", "$", "v", ")", ",", "ENT_NOQUOTES", ",", "'utf-8'", ")", ":", "$", "v", ";", "}", "// Add the query onto the array of values to pass", "// as arguments to sprintf", "array_unshift", "(", "$", "evals", ",", "$", "esql", ")", ";", "// Add the interpreted query to the list of executed queries", "$", "this", "->", "queries", "[", "]", "=", "[", "'time'", "=>", "$", "totalTime", ",", "'sql'", "=>", "sprintf", "(", "...", "$", "evals", ")", "]", ";", "$", "this", "->", "queries", "[", "'total_time'", "]", "+=", "$", "totalTime", ";", "// Set the last query to get rowcounts properly", "$", "this", "->", "driver", "->", "setLastQuery", "(", "$", "sql", ")", ";", "}" ]
Convert the prepared statement into readable sql @param array $vals @param string $sql @param int $totalTime @return void
[ "Convert", "the", "prepared", "statement", "into", "readable", "sql" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L1166-L1193
34,340
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._compileType
protected function _compileType(string $type='', string $table=''): string { $setArrayKeys = $this->state->getSetArrayKeys(); switch($type) { case 'insert': $paramCount = count($setArrayKeys); $params = array_fill(0, $paramCount, '?'); $sql = "INSERT INTO {$table} (" . implode(',', $setArrayKeys) . ")\nVALUES (".implode(',', $params).')'; break; case 'update': $setString = $this->state->getSetString(); $sql = "UPDATE {$table}\nSET {$setString}"; break; case 'replace': // @TODO implement $sql = ''; break; case 'delete': $sql = "DELETE FROM {$table}"; break; // Get queries default: $fromString = $this->state->getFromString(); $selectString = $this->state->getSelectString(); $sql = "SELECT * \nFROM {$fromString}"; // Set the select string if ( ! empty($selectString)) { // Replace the star with the selected fields $sql = str_replace('*', $selectString, $sql); } break; } return $sql; }
php
protected function _compileType(string $type='', string $table=''): string { $setArrayKeys = $this->state->getSetArrayKeys(); switch($type) { case 'insert': $paramCount = count($setArrayKeys); $params = array_fill(0, $paramCount, '?'); $sql = "INSERT INTO {$table} (" . implode(',', $setArrayKeys) . ")\nVALUES (".implode(',', $params).')'; break; case 'update': $setString = $this->state->getSetString(); $sql = "UPDATE {$table}\nSET {$setString}"; break; case 'replace': // @TODO implement $sql = ''; break; case 'delete': $sql = "DELETE FROM {$table}"; break; // Get queries default: $fromString = $this->state->getFromString(); $selectString = $this->state->getSelectString(); $sql = "SELECT * \nFROM {$fromString}"; // Set the select string if ( ! empty($selectString)) { // Replace the star with the selected fields $sql = str_replace('*', $selectString, $sql); } break; } return $sql; }
[ "protected", "function", "_compileType", "(", "string", "$", "type", "=", "''", ",", "string", "$", "table", "=", "''", ")", ":", "string", "{", "$", "setArrayKeys", "=", "$", "this", "->", "state", "->", "getSetArrayKeys", "(", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'insert'", ":", "$", "paramCount", "=", "count", "(", "$", "setArrayKeys", ")", ";", "$", "params", "=", "array_fill", "(", "0", ",", "$", "paramCount", ",", "'?'", ")", ";", "$", "sql", "=", "\"INSERT INTO {$table} (\"", ".", "implode", "(", "','", ",", "$", "setArrayKeys", ")", ".", "\")\\nVALUES (\"", ".", "implode", "(", "','", ",", "$", "params", ")", ".", "')'", ";", "break", ";", "case", "'update'", ":", "$", "setString", "=", "$", "this", "->", "state", "->", "getSetString", "(", ")", ";", "$", "sql", "=", "\"UPDATE {$table}\\nSET {$setString}\"", ";", "break", ";", "case", "'replace'", ":", "// @TODO implement", "$", "sql", "=", "''", ";", "break", ";", "case", "'delete'", ":", "$", "sql", "=", "\"DELETE FROM {$table}\"", ";", "break", ";", "// Get queries", "default", ":", "$", "fromString", "=", "$", "this", "->", "state", "->", "getFromString", "(", ")", ";", "$", "selectString", "=", "$", "this", "->", "state", "->", "getSelectString", "(", ")", ";", "$", "sql", "=", "\"SELECT * \\nFROM {$fromString}\"", ";", "// Set the select string", "if", "(", "!", "empty", "(", "$", "selectString", ")", ")", "{", "// Replace the star with the selected fields", "$", "sql", "=", "str_replace", "(", "'*'", ",", "$", "selectString", ",", "$", "sql", ")", ";", "}", "break", ";", "}", "return", "$", "sql", ";", "}" ]
Sub-method for generating sql strings @param string $type @param string $table @return string
[ "Sub", "-", "method", "for", "generating", "sql", "strings" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L1202-L1246
34,341
aviat4ion/Query
src/QueryBuilder.php
QueryBuilder._compile
protected function _compile(string $type='', string $table=''): string { // Get the base clause for the query $sql = $this->_compileType($type, $this->driver->quoteTable($table)); $clauses = [ 'queryMap', 'groupString', 'orderString', 'havingMap', ]; // Set each type of subclause foreach($clauses as $clause) { $func = 'get' . ucFirst($clause); $param = $this->state->$func(); if (\is_array($param)) { foreach($param as $q) { $sql .= $q['conjunction'] . $q['string']; } } else { $sql .= $param; } } // Set the limit via the class variables $limit = $this->state->getLimit(); if (is_numeric($limit)) { $sql = $this->driver->getSql()->limit($sql, $limit, $this->state->getOffset()); } // See if the query plan, rather than the // query data should be returned if ($this->explain === TRUE) { $sql = $this->driver->getSql()->explain($sql); } return $sql; }
php
protected function _compile(string $type='', string $table=''): string { // Get the base clause for the query $sql = $this->_compileType($type, $this->driver->quoteTable($table)); $clauses = [ 'queryMap', 'groupString', 'orderString', 'havingMap', ]; // Set each type of subclause foreach($clauses as $clause) { $func = 'get' . ucFirst($clause); $param = $this->state->$func(); if (\is_array($param)) { foreach($param as $q) { $sql .= $q['conjunction'] . $q['string']; } } else { $sql .= $param; } } // Set the limit via the class variables $limit = $this->state->getLimit(); if (is_numeric($limit)) { $sql = $this->driver->getSql()->limit($sql, $limit, $this->state->getOffset()); } // See if the query plan, rather than the // query data should be returned if ($this->explain === TRUE) { $sql = $this->driver->getSql()->explain($sql); } return $sql; }
[ "protected", "function", "_compile", "(", "string", "$", "type", "=", "''", ",", "string", "$", "table", "=", "''", ")", ":", "string", "{", "// Get the base clause for the query", "$", "sql", "=", "$", "this", "->", "_compileType", "(", "$", "type", ",", "$", "this", "->", "driver", "->", "quoteTable", "(", "$", "table", ")", ")", ";", "$", "clauses", "=", "[", "'queryMap'", ",", "'groupString'", ",", "'orderString'", ",", "'havingMap'", ",", "]", ";", "// Set each type of subclause", "foreach", "(", "$", "clauses", "as", "$", "clause", ")", "{", "$", "func", "=", "'get'", ".", "ucFirst", "(", "$", "clause", ")", ";", "$", "param", "=", "$", "this", "->", "state", "->", "$", "func", "(", ")", ";", "if", "(", "\\", "is_array", "(", "$", "param", ")", ")", "{", "foreach", "(", "$", "param", "as", "$", "q", ")", "{", "$", "sql", ".=", "$", "q", "[", "'conjunction'", "]", ".", "$", "q", "[", "'string'", "]", ";", "}", "}", "else", "{", "$", "sql", ".=", "$", "param", ";", "}", "}", "// Set the limit via the class variables", "$", "limit", "=", "$", "this", "->", "state", "->", "getLimit", "(", ")", ";", "if", "(", "is_numeric", "(", "$", "limit", ")", ")", "{", "$", "sql", "=", "$", "this", "->", "driver", "->", "getSql", "(", ")", "->", "limit", "(", "$", "sql", ",", "$", "limit", ",", "$", "this", "->", "state", "->", "getOffset", "(", ")", ")", ";", "}", "// See if the query plan, rather than the", "// query data should be returned", "if", "(", "$", "this", "->", "explain", "===", "TRUE", ")", "{", "$", "sql", "=", "$", "this", "->", "driver", "->", "getSql", "(", ")", "->", "explain", "(", "$", "sql", ")", ";", "}", "return", "$", "sql", ";", "}" ]
String together the sql statements for sending to the db @param string $type @param string $table @return string
[ "String", "together", "the", "sql", "statements", "for", "sending", "to", "the", "db" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/QueryBuilder.php#L1255-L1300
34,342
joomlatools/joomlatools-framework-activities
template/helper/activity.php
ComActivitiesTemplateHelperActivity._renderObject
protected function _renderObject(ComActivitiesActivityObjectInterface $object, KObjectConfig $config) { $config->append(array('html' => true, 'escaped_urls' => true, 'fqr' => false, 'links' => true)); if ($output = $object->getDisplayName()) { if ($config->html) { $output = $object->getDisplayName(); $attribs = $object->getAttributes() ? $this->buildAttributes($object->getAttributes()) : ''; if ($config->links && $url = $object->getUrl()) { // Make sure we have a fully qualified route. if ($config->fqr && !$url->getHost()) { $url->setUrl($this->getTemplate()->url()->toString(KHttpUrl::AUTHORITY)); } $url = $url->toString(KHttpUrl::FULL, $config->escaped_urls); $output = "<a {$attribs} href=\"{$url}\">{$output}</a>"; } else $output = "<span {$attribs}>{$output}</span>"; } } else $output = ''; return $output; }
php
protected function _renderObject(ComActivitiesActivityObjectInterface $object, KObjectConfig $config) { $config->append(array('html' => true, 'escaped_urls' => true, 'fqr' => false, 'links' => true)); if ($output = $object->getDisplayName()) { if ($config->html) { $output = $object->getDisplayName(); $attribs = $object->getAttributes() ? $this->buildAttributes($object->getAttributes()) : ''; if ($config->links && $url = $object->getUrl()) { // Make sure we have a fully qualified route. if ($config->fqr && !$url->getHost()) { $url->setUrl($this->getTemplate()->url()->toString(KHttpUrl::AUTHORITY)); } $url = $url->toString(KHttpUrl::FULL, $config->escaped_urls); $output = "<a {$attribs} href=\"{$url}\">{$output}</a>"; } else $output = "<span {$attribs}>{$output}</span>"; } } else $output = ''; return $output; }
[ "protected", "function", "_renderObject", "(", "ComActivitiesActivityObjectInterface", "$", "object", ",", "KObjectConfig", "$", "config", ")", "{", "$", "config", "->", "append", "(", "array", "(", "'html'", "=>", "true", ",", "'escaped_urls'", "=>", "true", ",", "'fqr'", "=>", "false", ",", "'links'", "=>", "true", ")", ")", ";", "if", "(", "$", "output", "=", "$", "object", "->", "getDisplayName", "(", ")", ")", "{", "if", "(", "$", "config", "->", "html", ")", "{", "$", "output", "=", "$", "object", "->", "getDisplayName", "(", ")", ";", "$", "attribs", "=", "$", "object", "->", "getAttributes", "(", ")", "?", "$", "this", "->", "buildAttributes", "(", "$", "object", "->", "getAttributes", "(", ")", ")", ":", "''", ";", "if", "(", "$", "config", "->", "links", "&&", "$", "url", "=", "$", "object", "->", "getUrl", "(", ")", ")", "{", "// Make sure we have a fully qualified route.", "if", "(", "$", "config", "->", "fqr", "&&", "!", "$", "url", "->", "getHost", "(", ")", ")", "{", "$", "url", "->", "setUrl", "(", "$", "this", "->", "getTemplate", "(", ")", "->", "url", "(", ")", "->", "toString", "(", "KHttpUrl", "::", "AUTHORITY", ")", ")", ";", "}", "$", "url", "=", "$", "url", "->", "toString", "(", "KHttpUrl", "::", "FULL", ",", "$", "config", "->", "escaped_urls", ")", ";", "$", "output", "=", "\"<a {$attribs} href=\\\"{$url}\\\">{$output}</a>\"", ";", "}", "else", "$", "output", "=", "\"<span {$attribs}>{$output}</span>\"", ";", "}", "}", "else", "$", "output", "=", "''", ";", "return", "$", "output", ";", "}" ]
Renders an activity object. @param ComActivitiesActivityObjectInterface $object The activity object. @param KObjectConfig $config The configuration object. @return string The rendered object.
[ "Renders", "an", "activity", "object", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/template/helper/activity.php#L94-L121
34,343
joomlatools/joomlatools-framework-activities
activity/logger/logger.php
ComActivitiesActivityLogger.log
public function log($action, KModelEntityInterface $object, KObjectIdentifierInterface $subject) { $controller = $this->getObject($this->_controller); if($controller instanceof KControllerModellable) { foreach($object as $entity) { // Only log if the entity status is valid. $status = $this->getActivityStatus($entity, $action); if (!empty($status) && $status !== KModelEntityInterface::STATUS_FAILED) { // Get the activity data $data = $this->getActivityData($entity, $subject, $action); // Set the status if(!isset($data['status'] )) { $data['status'] = $status; } // Set the action if(!isset($data['action'])) { $parts = explode('.', $action); $data['action'] = $parts[1]; } $controller->add($data); } } } }
php
public function log($action, KModelEntityInterface $object, KObjectIdentifierInterface $subject) { $controller = $this->getObject($this->_controller); if($controller instanceof KControllerModellable) { foreach($object as $entity) { // Only log if the entity status is valid. $status = $this->getActivityStatus($entity, $action); if (!empty($status) && $status !== KModelEntityInterface::STATUS_FAILED) { // Get the activity data $data = $this->getActivityData($entity, $subject, $action); // Set the status if(!isset($data['status'] )) { $data['status'] = $status; } // Set the action if(!isset($data['action'])) { $parts = explode('.', $action); $data['action'] = $parts[1]; } $controller->add($data); } } } }
[ "public", "function", "log", "(", "$", "action", ",", "KModelEntityInterface", "$", "object", ",", "KObjectIdentifierInterface", "$", "subject", ")", "{", "$", "controller", "=", "$", "this", "->", "getObject", "(", "$", "this", "->", "_controller", ")", ";", "if", "(", "$", "controller", "instanceof", "KControllerModellable", ")", "{", "foreach", "(", "$", "object", "as", "$", "entity", ")", "{", "// Only log if the entity status is valid.", "$", "status", "=", "$", "this", "->", "getActivityStatus", "(", "$", "entity", ",", "$", "action", ")", ";", "if", "(", "!", "empty", "(", "$", "status", ")", "&&", "$", "status", "!==", "KModelEntityInterface", "::", "STATUS_FAILED", ")", "{", "// Get the activity data", "$", "data", "=", "$", "this", "->", "getActivityData", "(", "$", "entity", ",", "$", "subject", ",", "$", "action", ")", ";", "// Set the status", "if", "(", "!", "isset", "(", "$", "data", "[", "'status'", "]", ")", ")", "{", "$", "data", "[", "'status'", "]", "=", "$", "status", ";", "}", "// Set the action", "if", "(", "!", "isset", "(", "$", "data", "[", "'action'", "]", ")", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "action", ")", ";", "$", "data", "[", "'action'", "]", "=", "$", "parts", "[", "1", "]", ";", "}", "$", "controller", "->", "add", "(", "$", "data", ")", ";", "}", "}", "}", "}" ]
Log an activity. @param string $action The action to log. @param KModelEntityInterface $object The activity object on which the action is performed. @param KObjectIdentifierInterface $subject The activity subject who is performing the action.
[ "Log", "an", "activity", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/logger/logger.php#L79-L111
34,344
joomlatools/joomlatools-framework-activities
activity/logger/logger.php
ComActivitiesActivityLogger.getActivityObject
public function getActivityObject(KCommandInterface $command) { $parts = explode('.', $command->getName()); // Properly fetch data for the event. if ($parts[0] == 'before') { $object = $command->getSubject()->getModel()->fetch(); } else { $object = $command->result; } return $object; }
php
public function getActivityObject(KCommandInterface $command) { $parts = explode('.', $command->getName()); // Properly fetch data for the event. if ($parts[0] == 'before') { $object = $command->getSubject()->getModel()->fetch(); } else { $object = $command->result; } return $object; }
[ "public", "function", "getActivityObject", "(", "KCommandInterface", "$", "command", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "command", "->", "getName", "(", ")", ")", ";", "// Properly fetch data for the event.", "if", "(", "$", "parts", "[", "0", "]", "==", "'before'", ")", "{", "$", "object", "=", "$", "command", "->", "getSubject", "(", ")", "->", "getModel", "(", ")", "->", "fetch", "(", ")", ";", "}", "else", "{", "$", "object", "=", "$", "command", "->", "result", ";", "}", "return", "$", "object", ";", "}" ]
Get the activity object. The activity object is the entity on which the action is executed. @param KCommandInterface $command The command. @return KModelEntityInterface The activity object.
[ "Get", "the", "activity", "object", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/logger/logger.php#L145-L157
34,345
joomlatools/joomlatools-framework-activities
activity/logger/logger.php
ComActivitiesActivityLogger.getActivityStatus
public function getActivityStatus(KModelEntityInterface $object, $action = null) { $status = $object->getStatus(); // Commands may change the original status of an action. if ($action == 'after.add' && $status == KModelEntityInterface::STATUS_UPDATED) { $status = KModelEntityInterface::STATUS_CREATED; } // Ignore non-changing edits. if ($action == 'after.edit' && $status == KModelEntityInterface::STATUS_FETCHED) { $status = null; } return $status; }
php
public function getActivityStatus(KModelEntityInterface $object, $action = null) { $status = $object->getStatus(); // Commands may change the original status of an action. if ($action == 'after.add' && $status == KModelEntityInterface::STATUS_UPDATED) { $status = KModelEntityInterface::STATUS_CREATED; } // Ignore non-changing edits. if ($action == 'after.edit' && $status == KModelEntityInterface::STATUS_FETCHED) { $status = null; } return $status; }
[ "public", "function", "getActivityStatus", "(", "KModelEntityInterface", "$", "object", ",", "$", "action", "=", "null", ")", "{", "$", "status", "=", "$", "object", "->", "getStatus", "(", ")", ";", "// Commands may change the original status of an action.", "if", "(", "$", "action", "==", "'after.add'", "&&", "$", "status", "==", "KModelEntityInterface", "::", "STATUS_UPDATED", ")", "{", "$", "status", "=", "KModelEntityInterface", "::", "STATUS_CREATED", ";", "}", "// Ignore non-changing edits.", "if", "(", "$", "action", "==", "'after.edit'", "&&", "$", "status", "==", "KModelEntityInterface", "::", "STATUS_FETCHED", ")", "{", "$", "status", "=", "null", ";", "}", "return", "$", "status", ";", "}" ]
Get the activity status. The activity status is the current status of the activity object. @param KModelEntityInterface $object The activity object. @param string $action The action being executed. @return string The activity status.
[ "Get", "the", "activity", "status", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/logger/logger.php#L168-L183
34,346
aviat4ion/Query
src/ConnectionManager.php
ConnectionManager.getInstance
public static function getInstance(): ConnectionManager { if (self::$instance === NULL) { self::$instance = new self(); } return self::$instance; }
php
public static function getInstance(): ConnectionManager { if (self::$instance === NULL) { self::$instance = new self(); } return self::$instance; }
[ "public", "static", "function", "getInstance", "(", ")", ":", "ConnectionManager", "{", "if", "(", "self", "::", "$", "instance", "===", "NULL", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Return a connection manager instance @staticvar null $instance @return ConnectionManager
[ "Return", "a", "connection", "manager", "instance" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/ConnectionManager.php#L85-L93
34,347
aviat4ion/Query
src/ConnectionManager.php
ConnectionManager.getConnection
public function getConnection($name = ''): QueryBuilderInterface { // If the parameter is a string, use it as an array index if (is_scalar($name) && isset($this->connections[$name])) { return $this->connections[$name]; } else if (empty($name) && ! empty($this->connections)) // Otherwise, return the last one { return end($this->connections); } // You should actually connect before trying to get a connection... throw new InvalidArgumentException('The specified connection does not exist'); }
php
public function getConnection($name = ''): QueryBuilderInterface { // If the parameter is a string, use it as an array index if (is_scalar($name) && isset($this->connections[$name])) { return $this->connections[$name]; } else if (empty($name) && ! empty($this->connections)) // Otherwise, return the last one { return end($this->connections); } // You should actually connect before trying to get a connection... throw new InvalidArgumentException('The specified connection does not exist'); }
[ "public", "function", "getConnection", "(", "$", "name", "=", "''", ")", ":", "QueryBuilderInterface", "{", "// If the parameter is a string, use it as an array index", "if", "(", "is_scalar", "(", "$", "name", ")", "&&", "isset", "(", "$", "this", "->", "connections", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "connections", "[", "$", "name", "]", ";", "}", "else", "if", "(", "empty", "(", "$", "name", ")", "&&", "!", "empty", "(", "$", "this", "->", "connections", ")", ")", "// Otherwise, return the last one", "{", "return", "end", "(", "$", "this", "->", "connections", ")", ";", "}", "// You should actually connect before trying to get a connection...", "throw", "new", "InvalidArgumentException", "(", "'The specified connection does not exist'", ")", ";", "}" ]
Returns the connection specified by the name given @param string|array|object $name @return QueryBuilderInterface @throws InvalidArgumentException
[ "Returns", "the", "connection", "specified", "by", "the", "name", "given" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/ConnectionManager.php#L102-L116
34,348
aviat4ion/Query
src/ConnectionManager.php
ConnectionManager.connect
public function connect(\stdClass $params): QueryBuilderInterface { list($dsn, $dbtype, $params, $options) = $this->parseParams($params); $dbtype = ucfirst($dbtype); $driver = "\\Query\\Drivers\\{$dbtype}\\Driver"; // Create the database connection $db = ! empty($params->user) ? new $driver($dsn, $params->user, $params->pass, $options) : new $driver($dsn, '', '', $options); // Set the table prefix, if it exists if (isset($params->prefix)) { $db->setTablePrefix($params->prefix); } // Create Query Builder object $conn = new QueryBuilder($db, new QueryParser($db)); // Save it for later if (isset($params->alias)) { $this->connections[$params->alias] = $conn; } else { $this->connections[] = $conn; } return $conn; }
php
public function connect(\stdClass $params): QueryBuilderInterface { list($dsn, $dbtype, $params, $options) = $this->parseParams($params); $dbtype = ucfirst($dbtype); $driver = "\\Query\\Drivers\\{$dbtype}\\Driver"; // Create the database connection $db = ! empty($params->user) ? new $driver($dsn, $params->user, $params->pass, $options) : new $driver($dsn, '', '', $options); // Set the table prefix, if it exists if (isset($params->prefix)) { $db->setTablePrefix($params->prefix); } // Create Query Builder object $conn = new QueryBuilder($db, new QueryParser($db)); // Save it for later if (isset($params->alias)) { $this->connections[$params->alias] = $conn; } else { $this->connections[] = $conn; } return $conn; }
[ "public", "function", "connect", "(", "\\", "stdClass", "$", "params", ")", ":", "QueryBuilderInterface", "{", "list", "(", "$", "dsn", ",", "$", "dbtype", ",", "$", "params", ",", "$", "options", ")", "=", "$", "this", "->", "parseParams", "(", "$", "params", ")", ";", "$", "dbtype", "=", "ucfirst", "(", "$", "dbtype", ")", ";", "$", "driver", "=", "\"\\\\Query\\\\Drivers\\\\{$dbtype}\\\\Driver\"", ";", "// Create the database connection", "$", "db", "=", "!", "empty", "(", "$", "params", "->", "user", ")", "?", "new", "$", "driver", "(", "$", "dsn", ",", "$", "params", "->", "user", ",", "$", "params", "->", "pass", ",", "$", "options", ")", ":", "new", "$", "driver", "(", "$", "dsn", ",", "''", ",", "''", ",", "$", "options", ")", ";", "// Set the table prefix, if it exists", "if", "(", "isset", "(", "$", "params", "->", "prefix", ")", ")", "{", "$", "db", "->", "setTablePrefix", "(", "$", "params", "->", "prefix", ")", ";", "}", "// Create Query Builder object", "$", "conn", "=", "new", "QueryBuilder", "(", "$", "db", ",", "new", "QueryParser", "(", "$", "db", ")", ")", ";", "// Save it for later", "if", "(", "isset", "(", "$", "params", "->", "alias", ")", ")", "{", "$", "this", "->", "connections", "[", "$", "params", "->", "alias", "]", "=", "$", "conn", ";", "}", "else", "{", "$", "this", "->", "connections", "[", "]", "=", "$", "conn", ";", "}", "return", "$", "conn", ";", "}" ]
Parse the passed parameters and return a connection @param \stdClass $params @return QueryBuilderInterface
[ "Parse", "the", "passed", "parameters", "and", "return", "a", "connection" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/ConnectionManager.php#L124-L157
34,349
aviat4ion/Query
src/ConnectionManager.php
ConnectionManager.parseParams
public function parseParams(\stdClass $params): array { $params->type = strtolower($params->type); $dbtype = ($params->type !== 'postgresql') ? $params->type : 'pgsql'; $dbtype = ucfirst($dbtype); // Make sure the class exists if ( ! class_exists("\\Query\\Drivers\\{$dbtype}\\Driver")) { throw new BadDBDriverException('Database driver does not exist, or is not supported'); } // Set additional PDO options $options = []; if (isset($params->options)) { $options = (array) $params->options; } // Create the dsn for the database to connect to if(strtolower($dbtype) === 'sqlite') { $dsn = $params->file; } else { $dsn = $this->createDsn($dbtype, $params); } return [$dsn, $dbtype, $params, $options]; }
php
public function parseParams(\stdClass $params): array { $params->type = strtolower($params->type); $dbtype = ($params->type !== 'postgresql') ? $params->type : 'pgsql'; $dbtype = ucfirst($dbtype); // Make sure the class exists if ( ! class_exists("\\Query\\Drivers\\{$dbtype}\\Driver")) { throw new BadDBDriverException('Database driver does not exist, or is not supported'); } // Set additional PDO options $options = []; if (isset($params->options)) { $options = (array) $params->options; } // Create the dsn for the database to connect to if(strtolower($dbtype) === 'sqlite') { $dsn = $params->file; } else { $dsn = $this->createDsn($dbtype, $params); } return [$dsn, $dbtype, $params, $options]; }
[ "public", "function", "parseParams", "(", "\\", "stdClass", "$", "params", ")", ":", "array", "{", "$", "params", "->", "type", "=", "strtolower", "(", "$", "params", "->", "type", ")", ";", "$", "dbtype", "=", "(", "$", "params", "->", "type", "!==", "'postgresql'", ")", "?", "$", "params", "->", "type", ":", "'pgsql'", ";", "$", "dbtype", "=", "ucfirst", "(", "$", "dbtype", ")", ";", "// Make sure the class exists", "if", "(", "!", "class_exists", "(", "\"\\\\Query\\\\Drivers\\\\{$dbtype}\\\\Driver\"", ")", ")", "{", "throw", "new", "BadDBDriverException", "(", "'Database driver does not exist, or is not supported'", ")", ";", "}", "// Set additional PDO options", "$", "options", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "params", "->", "options", ")", ")", "{", "$", "options", "=", "(", "array", ")", "$", "params", "->", "options", ";", "}", "// Create the dsn for the database to connect to", "if", "(", "strtolower", "(", "$", "dbtype", ")", "===", "'sqlite'", ")", "{", "$", "dsn", "=", "$", "params", "->", "file", ";", "}", "else", "{", "$", "dsn", "=", "$", "this", "->", "createDsn", "(", "$", "dbtype", ",", "$", "params", ")", ";", "}", "return", "[", "$", "dsn", ",", "$", "dbtype", ",", "$", "params", ",", "$", "options", "]", ";", "}" ]
Parses params into a dsn and option array @param \stdClass $params @return array @throws BadDBDriverException
[ "Parses", "params", "into", "a", "dsn", "and", "option", "array" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/ConnectionManager.php#L166-L198
34,350
aviat4ion/Query
src/ConnectionManager.php
ConnectionManager.createDsn
private function createDsn(string $dbtype, \stdClass $params): string { $pairs = []; if ( ! empty($params->database)) { $pairs[] = implode('=', ['dbname', $params->database]); } $skip = [ 'name' => 'name', 'pass' => 'pass', 'user' => 'user', 'type' => 'type', 'prefix' => 'prefix', 'options' => 'options', 'database' => 'database', 'alias' => 'alias' ]; foreach($params as $key => $val) { if (( ! array_key_exists($key, $skip)) && ! empty($val)) { $pairs[] = implode('=', [$key, $val]); } } return strtolower($dbtype) . ':' . implode(';', $pairs); }
php
private function createDsn(string $dbtype, \stdClass $params): string { $pairs = []; if ( ! empty($params->database)) { $pairs[] = implode('=', ['dbname', $params->database]); } $skip = [ 'name' => 'name', 'pass' => 'pass', 'user' => 'user', 'type' => 'type', 'prefix' => 'prefix', 'options' => 'options', 'database' => 'database', 'alias' => 'alias' ]; foreach($params as $key => $val) { if (( ! array_key_exists($key, $skip)) && ! empty($val)) { $pairs[] = implode('=', [$key, $val]); } } return strtolower($dbtype) . ':' . implode(';', $pairs); }
[ "private", "function", "createDsn", "(", "string", "$", "dbtype", ",", "\\", "stdClass", "$", "params", ")", ":", "string", "{", "$", "pairs", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "params", "->", "database", ")", ")", "{", "$", "pairs", "[", "]", "=", "implode", "(", "'='", ",", "[", "'dbname'", ",", "$", "params", "->", "database", "]", ")", ";", "}", "$", "skip", "=", "[", "'name'", "=>", "'name'", ",", "'pass'", "=>", "'pass'", ",", "'user'", "=>", "'user'", ",", "'type'", "=>", "'type'", ",", "'prefix'", "=>", "'prefix'", ",", "'options'", "=>", "'options'", ",", "'database'", "=>", "'database'", ",", "'alias'", "=>", "'alias'", "]", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "skip", ")", ")", "&&", "!", "empty", "(", "$", "val", ")", ")", "{", "$", "pairs", "[", "]", "=", "implode", "(", "'='", ",", "[", "$", "key", ",", "$", "val", "]", ")", ";", "}", "}", "return", "strtolower", "(", "$", "dbtype", ")", ".", "':'", ".", "implode", "(", "';'", ",", "$", "pairs", ")", ";", "}" ]
Create the dsn from the db type and params @codeCoverageIgnore @param string $dbtype @param \stdClass $params @return string
[ "Create", "the", "dsn", "from", "the", "db", "type", "and", "params" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/ConnectionManager.php#L208-L237
34,351
aviat4ion/Query
src/State.php
State.appendMap
public function appendMap(string $conjunction = '', string $string = '', string $type = ''): self { $this->queryMap[] = [ 'type' => $type, 'conjunction' => $conjunction, 'string' => $string ]; return $this; }
php
public function appendMap(string $conjunction = '', string $string = '', string $type = ''): self { $this->queryMap[] = [ 'type' => $type, 'conjunction' => $conjunction, 'string' => $string ]; return $this; }
[ "public", "function", "appendMap", "(", "string", "$", "conjunction", "=", "''", ",", "string", "$", "string", "=", "''", ",", "string", "$", "type", "=", "''", ")", ":", "self", "{", "$", "this", "->", "queryMap", "[", "]", "=", "[", "'type'", "=>", "$", "type", ",", "'conjunction'", "=>", "$", "conjunction", ",", "'string'", "=>", "$", "string", "]", ";", "return", "$", "this", ";", "}" ]
Add an additional set of mapping pairs to a internal map @param string $conjunction @param string $string @param string $type @return State
[ "Add", "an", "additional", "set", "of", "mapping", "pairs", "to", "a", "internal", "map" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/State.php#L400-L408
34,352
netgen-layouts/content-browser-ezplatform
lib/Backend/EzPublishBackend.php
EzPublishBackend.buildItem
private function buildItem(SearchHit $searchHit): Item { /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */ $location = $searchHit->valueObject; /** @var \eZ\Publish\API\Repository\Values\Content\Content $content */ $content = $this->repository->sudo( static function (Repository $repository) use ($location): Content { return $repository->getContentService()->loadContentByContentInfo( $location->contentInfo ); } ); return new Item( $location, $content, $this->config->getItemType() === 'ezlocation' ? $location->id : $location->contentInfo->id, $this->isSelectable($content) ); }
php
private function buildItem(SearchHit $searchHit): Item { /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */ $location = $searchHit->valueObject; /** @var \eZ\Publish\API\Repository\Values\Content\Content $content */ $content = $this->repository->sudo( static function (Repository $repository) use ($location): Content { return $repository->getContentService()->loadContentByContentInfo( $location->contentInfo ); } ); return new Item( $location, $content, $this->config->getItemType() === 'ezlocation' ? $location->id : $location->contentInfo->id, $this->isSelectable($content) ); }
[ "private", "function", "buildItem", "(", "SearchHit", "$", "searchHit", ")", ":", "Item", "{", "/** @var \\eZ\\Publish\\API\\Repository\\Values\\Content\\Location $location */", "$", "location", "=", "$", "searchHit", "->", "valueObject", ";", "/** @var \\eZ\\Publish\\API\\Repository\\Values\\Content\\Content $content */", "$", "content", "=", "$", "this", "->", "repository", "->", "sudo", "(", "static", "function", "(", "Repository", "$", "repository", ")", "use", "(", "$", "location", ")", ":", "Content", "{", "return", "$", "repository", "->", "getContentService", "(", ")", "->", "loadContentByContentInfo", "(", "$", "location", "->", "contentInfo", ")", ";", "}", ")", ";", "return", "new", "Item", "(", "$", "location", ",", "$", "content", ",", "$", "this", "->", "config", "->", "getItemType", "(", ")", "===", "'ezlocation'", "?", "$", "location", "->", "id", ":", "$", "location", "->", "contentInfo", "->", "id", ",", "$", "this", "->", "isSelectable", "(", "$", "content", ")", ")", ";", "}" ]
Builds the item from provided search hit.
[ "Builds", "the", "item", "from", "provided", "search", "hit", "." ]
1f189f154933b92757d8072aea1ba95ac07c1167
https://github.com/netgen-layouts/content-browser-ezplatform/blob/1f189f154933b92757d8072aea1ba95ac07c1167/lib/Backend/EzPublishBackend.php#L318-L340
34,353
netgen-layouts/content-browser-ezplatform
lib/Backend/EzPublishBackend.php
EzPublishBackend.buildItems
private function buildItems(SearchResult $searchResult): array { return array_map( function (SearchHit $searchHit): Item { return $this->buildItem($searchHit); }, $searchResult->searchHits ); }
php
private function buildItems(SearchResult $searchResult): array { return array_map( function (SearchHit $searchHit): Item { return $this->buildItem($searchHit); }, $searchResult->searchHits ); }
[ "private", "function", "buildItems", "(", "SearchResult", "$", "searchResult", ")", ":", "array", "{", "return", "array_map", "(", "function", "(", "SearchHit", "$", "searchHit", ")", ":", "Item", "{", "return", "$", "this", "->", "buildItem", "(", "$", "searchHit", ")", ";", "}", ",", "$", "searchResult", "->", "searchHits", ")", ";", "}" ]
Builds the items from search result and its hits. @return \Netgen\ContentBrowser\Ez\Item\EzPublish\Item[]
[ "Builds", "the", "items", "from", "search", "result", "and", "its", "hits", "." ]
1f189f154933b92757d8072aea1ba95ac07c1167
https://github.com/netgen-layouts/content-browser-ezplatform/blob/1f189f154933b92757d8072aea1ba95ac07c1167/lib/Backend/EzPublishBackend.php#L347-L355
34,354
netgen-layouts/content-browser-ezplatform
lib/Backend/EzPublishBackend.php
EzPublishBackend.getContentTypeIds
private function getContentTypeIds(array $contentTypeIdentifiers): array { $idList = []; foreach ($contentTypeIdentifiers as $identifier) { try { $contentType = $this->contentTypeHandler->loadByIdentifier($identifier); $idList[] = $contentType->id; } catch (APINotFoundException $e) { continue; } } return $idList; }
php
private function getContentTypeIds(array $contentTypeIdentifiers): array { $idList = []; foreach ($contentTypeIdentifiers as $identifier) { try { $contentType = $this->contentTypeHandler->loadByIdentifier($identifier); $idList[] = $contentType->id; } catch (APINotFoundException $e) { continue; } } return $idList; }
[ "private", "function", "getContentTypeIds", "(", "array", "$", "contentTypeIdentifiers", ")", ":", "array", "{", "$", "idList", "=", "[", "]", ";", "foreach", "(", "$", "contentTypeIdentifiers", "as", "$", "identifier", ")", "{", "try", "{", "$", "contentType", "=", "$", "this", "->", "contentTypeHandler", "->", "loadByIdentifier", "(", "$", "identifier", ")", ";", "$", "idList", "[", "]", "=", "$", "contentType", "->", "id", ";", "}", "catch", "(", "APINotFoundException", "$", "e", ")", "{", "continue", ";", "}", "}", "return", "$", "idList", ";", "}" ]
Returns content type IDs for all existing content types. @return int[]
[ "Returns", "content", "type", "IDs", "for", "all", "existing", "content", "types", "." ]
1f189f154933b92757d8072aea1ba95ac07c1167
https://github.com/netgen-layouts/content-browser-ezplatform/blob/1f189f154933b92757d8072aea1ba95ac07c1167/lib/Backend/EzPublishBackend.php#L362-L376
34,355
netgen-layouts/content-browser-ezplatform
lib/Backend/EzPublishBackend.php
EzPublishBackend.isSelectable
private function isSelectable(Content $content): bool { if (!$this->config->hasParameter('allowed_content_types')) { return true; } if ($this->allowedContentTypeIds === null) { $this->allowedContentTypeIds = []; $allowedContentTypes = $this->config->getParameter('allowed_content_types'); if (is_string($allowedContentTypes) && $allowedContentTypes !== '') { $allowedContentTypes = array_map('trim', explode(',', $allowedContentTypes)); $this->allowedContentTypeIds = $this->getContentTypeIds($allowedContentTypes); } } if (count($this->allowedContentTypeIds) === 0) { return true; } return in_array($content->contentInfo->contentTypeId, $this->allowedContentTypeIds, true); }
php
private function isSelectable(Content $content): bool { if (!$this->config->hasParameter('allowed_content_types')) { return true; } if ($this->allowedContentTypeIds === null) { $this->allowedContentTypeIds = []; $allowedContentTypes = $this->config->getParameter('allowed_content_types'); if (is_string($allowedContentTypes) && $allowedContentTypes !== '') { $allowedContentTypes = array_map('trim', explode(',', $allowedContentTypes)); $this->allowedContentTypeIds = $this->getContentTypeIds($allowedContentTypes); } } if (count($this->allowedContentTypeIds) === 0) { return true; } return in_array($content->contentInfo->contentTypeId, $this->allowedContentTypeIds, true); }
[ "private", "function", "isSelectable", "(", "Content", "$", "content", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "config", "->", "hasParameter", "(", "'allowed_content_types'", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "allowedContentTypeIds", "===", "null", ")", "{", "$", "this", "->", "allowedContentTypeIds", "=", "[", "]", ";", "$", "allowedContentTypes", "=", "$", "this", "->", "config", "->", "getParameter", "(", "'allowed_content_types'", ")", ";", "if", "(", "is_string", "(", "$", "allowedContentTypes", ")", "&&", "$", "allowedContentTypes", "!==", "''", ")", "{", "$", "allowedContentTypes", "=", "array_map", "(", "'trim'", ",", "explode", "(", "','", ",", "$", "allowedContentTypes", ")", ")", ";", "$", "this", "->", "allowedContentTypeIds", "=", "$", "this", "->", "getContentTypeIds", "(", "$", "allowedContentTypes", ")", ";", "}", "}", "if", "(", "count", "(", "$", "this", "->", "allowedContentTypeIds", ")", "===", "0", ")", "{", "return", "true", ";", "}", "return", "in_array", "(", "$", "content", "->", "contentInfo", "->", "contentTypeId", ",", "$", "this", "->", "allowedContentTypeIds", ",", "true", ")", ";", "}" ]
Returns if the provided content is selectable.
[ "Returns", "if", "the", "provided", "content", "is", "selectable", "." ]
1f189f154933b92757d8072aea1ba95ac07c1167
https://github.com/netgen-layouts/content-browser-ezplatform/blob/1f189f154933b92757d8072aea1ba95ac07c1167/lib/Backend/EzPublishBackend.php#L381-L402
34,356
aviat4ion/Query
src/Drivers/AbstractUtil.php
AbstractUtil.createTable
public function createTable($name, $fields, array $constraints=[], $ifNotExists=TRUE) { $existsStr = $ifNotExists ? ' IF NOT EXISTS ' : ' '; // Reorganize into an array indexed with column information // Eg $columnArray[$colname] = array( // 'type' => ..., // 'constraint' => ..., // 'index' => ..., // ) $columnArray = \arrayZipper([ 'type' => $fields, 'constraint' => $constraints ]); // Join column definitions together $columns = []; foreach($columnArray as $n => $props) { $str = $this->getDriver()->quoteIdent($n); $str .= isset($props['type']) ? " {$props['type']}" : ""; $str .= isset($props['constraint']) ? " {$props['constraint']}" : ""; $columns[] = $str; } // Generate the sql for the creation of the table $sql = 'CREATE TABLE'.$existsStr.$this->getDriver()->quoteTable($name).' ('; $sql .= implode(', ', $columns); $sql .= ')'; return $sql; }
php
public function createTable($name, $fields, array $constraints=[], $ifNotExists=TRUE) { $existsStr = $ifNotExists ? ' IF NOT EXISTS ' : ' '; // Reorganize into an array indexed with column information // Eg $columnArray[$colname] = array( // 'type' => ..., // 'constraint' => ..., // 'index' => ..., // ) $columnArray = \arrayZipper([ 'type' => $fields, 'constraint' => $constraints ]); // Join column definitions together $columns = []; foreach($columnArray as $n => $props) { $str = $this->getDriver()->quoteIdent($n); $str .= isset($props['type']) ? " {$props['type']}" : ""; $str .= isset($props['constraint']) ? " {$props['constraint']}" : ""; $columns[] = $str; } // Generate the sql for the creation of the table $sql = 'CREATE TABLE'.$existsStr.$this->getDriver()->quoteTable($name).' ('; $sql .= implode(', ', $columns); $sql .= ')'; return $sql; }
[ "public", "function", "createTable", "(", "$", "name", ",", "$", "fields", ",", "array", "$", "constraints", "=", "[", "]", ",", "$", "ifNotExists", "=", "TRUE", ")", "{", "$", "existsStr", "=", "$", "ifNotExists", "?", "' IF NOT EXISTS '", ":", "' '", ";", "// Reorganize into an array indexed with column information", "// Eg $columnArray[$colname] = array(", "// \t\t'type' => ...,", "// \t\t'constraint' => ...,", "// \t\t'index' => ...,", "// )", "$", "columnArray", "=", "\\", "arrayZipper", "(", "[", "'type'", "=>", "$", "fields", ",", "'constraint'", "=>", "$", "constraints", "]", ")", ";", "// Join column definitions together", "$", "columns", "=", "[", "]", ";", "foreach", "(", "$", "columnArray", "as", "$", "n", "=>", "$", "props", ")", "{", "$", "str", "=", "$", "this", "->", "getDriver", "(", ")", "->", "quoteIdent", "(", "$", "n", ")", ";", "$", "str", ".=", "isset", "(", "$", "props", "[", "'type'", "]", ")", "?", "\" {$props['type']}\"", ":", "\"\"", ";", "$", "str", ".=", "isset", "(", "$", "props", "[", "'constraint'", "]", ")", "?", "\" {$props['constraint']}\"", ":", "\"\"", ";", "$", "columns", "[", "]", "=", "$", "str", ";", "}", "// Generate the sql for the creation of the table", "$", "sql", "=", "'CREATE TABLE'", ".", "$", "existsStr", ".", "$", "this", "->", "getDriver", "(", ")", "->", "quoteTable", "(", "$", "name", ")", ".", "' ('", ";", "$", "sql", ".=", "implode", "(", "', '", ",", "$", "columns", ")", ";", "$", "sql", ".=", "')'", ";", "return", "$", "sql", ";", "}" ]
Convenience public function to generate sql for creating a db table @param string $name @param array $fields @param array $constraints @param bool $ifNotExists @return string
[ "Convenience", "public", "function", "to", "generate", "sql", "for", "creating", "a", "db", "table" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractUtil.php#L60-L92
34,357
usemarkup/addressing
Renderer/SerializableAddressAdapter.php
SerializableAddressAdapter.getStreetAddressLine
public function getStreetAddressLine($lineNumber) { $lines = $this->getStreetAddressLines(); if (!isset($lines[$lineNumber-1])) { return null; } return $lines[$lineNumber-1]; }
php
public function getStreetAddressLine($lineNumber) { $lines = $this->getStreetAddressLines(); if (!isset($lines[$lineNumber-1])) { return null; } return $lines[$lineNumber-1]; }
[ "public", "function", "getStreetAddressLine", "(", "$", "lineNumber", ")", "{", "$", "lines", "=", "$", "this", "->", "getStreetAddressLines", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "lines", "[", "$", "lineNumber", "-", "1", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "lines", "[", "$", "lineNumber", "-", "1", "]", ";", "}" ]
Gets the numbered address line, counting from one. If there is no address line for provided number, return null. @param int $lineNumber @return string|null
[ "Gets", "the", "numbered", "address", "line", "counting", "from", "one", ".", "If", "there", "is", "no", "address", "line", "for", "provided", "number", "return", "null", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Renderer/SerializableAddressAdapter.php#L59-L67
34,358
usemarkup/addressing
Iso/Iso3166Converter.php
Iso3166Converter.convertAlpha2ToAlpha3
public function convertAlpha2ToAlpha3($alpha2) { if (!isset(self::$codes[$alpha2])) { return null; } return self::$codes[$alpha2]; }
php
public function convertAlpha2ToAlpha3($alpha2) { if (!isset(self::$codes[$alpha2])) { return null; } return self::$codes[$alpha2]; }
[ "public", "function", "convertAlpha2ToAlpha3", "(", "$", "alpha2", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "codes", "[", "$", "alpha2", "]", ")", ")", "{", "return", "null", ";", "}", "return", "self", "::", "$", "codes", "[", "$", "alpha2", "]", ";", "}" ]
Gets the ISO3166 alpha-3 code that corresponds to the provided alpha-2 code. @param string $alpha2 @return string|null
[ "Gets", "the", "ISO3166", "alpha", "-", "3", "code", "that", "corresponds", "to", "the", "provided", "alpha", "-", "2", "code", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Iso/Iso3166Converter.php#L268-L275
34,359
usemarkup/addressing
Iso/Iso3166Converter.php
Iso3166Converter.convertAlpha3ToAlpha2
public function convertAlpha3ToAlpha2($alpha3) { $alpha2 = array_search($alpha3, self::$codes); if (false === $alpha2) { return null; } return (string) $alpha2; }
php
public function convertAlpha3ToAlpha2($alpha3) { $alpha2 = array_search($alpha3, self::$codes); if (false === $alpha2) { return null; } return (string) $alpha2; }
[ "public", "function", "convertAlpha3ToAlpha2", "(", "$", "alpha3", ")", "{", "$", "alpha2", "=", "array_search", "(", "$", "alpha3", ",", "self", "::", "$", "codes", ")", ";", "if", "(", "false", "===", "$", "alpha2", ")", "{", "return", "null", ";", "}", "return", "(", "string", ")", "$", "alpha2", ";", "}" ]
Gets the ISO3166 alpha-2 code that corresponds to the provided alpha-3 code. @param string $alpha3 @return string|null
[ "Gets", "the", "ISO3166", "alpha", "-", "2", "code", "that", "corresponds", "to", "the", "provided", "alpha", "-", "3", "code", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Iso/Iso3166Converter.php#L283-L291
34,360
usemarkup/addressing
Canonicalizer/PostalCodeCanonicalizer.php
PostalCodeCanonicalizer.canonicalizeForCountry
public function canonicalizeForCountry($postalCode, $country) { switch ($country) { case 'GB': case 'IM': case 'JE': case 'GG': case 'GI': $ukCanonicalizer = new UnitedKingdomPostcodeCanonicalizer(); return $ukCanonicalizer->canonicalize($postalCode); case 'SE': $seCanonicalizer = new SwedenPostalCodeCanonicalizer(); return $seCanonicalizer->canonicalize($postalCode); case 'FI': case 'IT': case 'ES': $fiveDigitCanonicalizer = new FixedConsecutiveDigitPostalCodeCanonicalizer(5); return $fiveDigitCanonicalizer->canonicalize($postalCode); case 'PT': $variant = new CombinedPostalCodeVariant([new PostalCodeVariant([4]), new PostalCodeVariant([4, 3], '-')]); return $variant->format($postalCode); case 'NL': $nlCanonicalizer = new NetherlandsPostalCodeCanonicalizer(); return $nlCanonicalizer->canonicalize($postalCode); case 'NO': case 'DK': $fourDigitCanonicalizer = new FixedConsecutiveDigitPostalCodeCanonicalizer(4); return $fourDigitCanonicalizer->canonicalize($postalCode); break; case 'CA': $caCanonicalizer = new CanadaPostalCodeCanonicalizer(); return $caCanonicalizer->canonicalize($postalCode); default: return $postalCode; } }
php
public function canonicalizeForCountry($postalCode, $country) { switch ($country) { case 'GB': case 'IM': case 'JE': case 'GG': case 'GI': $ukCanonicalizer = new UnitedKingdomPostcodeCanonicalizer(); return $ukCanonicalizer->canonicalize($postalCode); case 'SE': $seCanonicalizer = new SwedenPostalCodeCanonicalizer(); return $seCanonicalizer->canonicalize($postalCode); case 'FI': case 'IT': case 'ES': $fiveDigitCanonicalizer = new FixedConsecutiveDigitPostalCodeCanonicalizer(5); return $fiveDigitCanonicalizer->canonicalize($postalCode); case 'PT': $variant = new CombinedPostalCodeVariant([new PostalCodeVariant([4]), new PostalCodeVariant([4, 3], '-')]); return $variant->format($postalCode); case 'NL': $nlCanonicalizer = new NetherlandsPostalCodeCanonicalizer(); return $nlCanonicalizer->canonicalize($postalCode); case 'NO': case 'DK': $fourDigitCanonicalizer = new FixedConsecutiveDigitPostalCodeCanonicalizer(4); return $fourDigitCanonicalizer->canonicalize($postalCode); break; case 'CA': $caCanonicalizer = new CanadaPostalCodeCanonicalizer(); return $caCanonicalizer->canonicalize($postalCode); default: return $postalCode; } }
[ "public", "function", "canonicalizeForCountry", "(", "$", "postalCode", ",", "$", "country", ")", "{", "switch", "(", "$", "country", ")", "{", "case", "'GB'", ":", "case", "'IM'", ":", "case", "'JE'", ":", "case", "'GG'", ":", "case", "'GI'", ":", "$", "ukCanonicalizer", "=", "new", "UnitedKingdomPostcodeCanonicalizer", "(", ")", ";", "return", "$", "ukCanonicalizer", "->", "canonicalize", "(", "$", "postalCode", ")", ";", "case", "'SE'", ":", "$", "seCanonicalizer", "=", "new", "SwedenPostalCodeCanonicalizer", "(", ")", ";", "return", "$", "seCanonicalizer", "->", "canonicalize", "(", "$", "postalCode", ")", ";", "case", "'FI'", ":", "case", "'IT'", ":", "case", "'ES'", ":", "$", "fiveDigitCanonicalizer", "=", "new", "FixedConsecutiveDigitPostalCodeCanonicalizer", "(", "5", ")", ";", "return", "$", "fiveDigitCanonicalizer", "->", "canonicalize", "(", "$", "postalCode", ")", ";", "case", "'PT'", ":", "$", "variant", "=", "new", "CombinedPostalCodeVariant", "(", "[", "new", "PostalCodeVariant", "(", "[", "4", "]", ")", ",", "new", "PostalCodeVariant", "(", "[", "4", ",", "3", "]", ",", "'-'", ")", "]", ")", ";", "return", "$", "variant", "->", "format", "(", "$", "postalCode", ")", ";", "case", "'NL'", ":", "$", "nlCanonicalizer", "=", "new", "NetherlandsPostalCodeCanonicalizer", "(", ")", ";", "return", "$", "nlCanonicalizer", "->", "canonicalize", "(", "$", "postalCode", ")", ";", "case", "'NO'", ":", "case", "'DK'", ":", "$", "fourDigitCanonicalizer", "=", "new", "FixedConsecutiveDigitPostalCodeCanonicalizer", "(", "4", ")", ";", "return", "$", "fourDigitCanonicalizer", "->", "canonicalize", "(", "$", "postalCode", ")", ";", "break", ";", "case", "'CA'", ":", "$", "caCanonicalizer", "=", "new", "CanadaPostalCodeCanonicalizer", "(", ")", ";", "return", "$", "caCanonicalizer", "->", "canonicalize", "(", "$", "postalCode", ")", ";", "default", ":", "return", "$", "postalCode", ";", "}", "}" ]
Canonicalizes a provided postal code for a given country if it is possible to do so, otherwise returns the postal code unmodified. @param string $postalCode A postal code string. @param string $country The ISO3166 alpha-2 representation of a country. @return string
[ "Canonicalizes", "a", "provided", "postal", "code", "for", "a", "given", "country", "if", "it", "is", "possible", "to", "do", "so", "otherwise", "returns", "the", "postal", "code", "unmodified", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Canonicalizer/PostalCodeCanonicalizer.php#L18-L66
34,361
usemarkup/addressing
Canonicalizer/CanonicalizeAddressDecorator.php
CanonicalizeAddressDecorator.getPostalCode
public function getPostalCode() { $canonicalizer = new PostalCodeCanonicalizer(); return $canonicalizer->canonicalizeForCountry($this->address->getPostalCode(), $this->address->getCountry()); }
php
public function getPostalCode() { $canonicalizer = new PostalCodeCanonicalizer(); return $canonicalizer->canonicalizeForCountry($this->address->getPostalCode(), $this->address->getCountry()); }
[ "public", "function", "getPostalCode", "(", ")", "{", "$", "canonicalizer", "=", "new", "PostalCodeCanonicalizer", "(", ")", ";", "return", "$", "canonicalizer", "->", "canonicalizeForCountry", "(", "$", "this", "->", "address", "->", "getPostalCode", "(", ")", ",", "$", "this", "->", "address", "->", "getCountry", "(", ")", ")", ";", "}" ]
Gets the postal code for this address. If no postal code is indicated as part of the address information, returns an empty string. @return string
[ "Gets", "the", "postal", "code", "for", "this", "address", ".", "If", "no", "postal", "code", "is", "indicated", "as", "part", "of", "the", "address", "information", "returns", "an", "empty", "string", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Canonicalizer/CanonicalizeAddressDecorator.php#L93-L98
34,362
usemarkup/addressing
Provider/CountryNameProvider.php
CountryNameProvider.loadCountriesForLocale
private function loadCountriesForLocale($locale) { //load from Symfony Intl component $regionBundle = Intl::getRegionBundle(); $this->displayCountries[$locale] = $regionBundle->getCountryNames($locale); }
php
private function loadCountriesForLocale($locale) { //load from Symfony Intl component $regionBundle = Intl::getRegionBundle(); $this->displayCountries[$locale] = $regionBundle->getCountryNames($locale); }
[ "private", "function", "loadCountriesForLocale", "(", "$", "locale", ")", "{", "//load from Symfony Intl component", "$", "regionBundle", "=", "Intl", "::", "getRegionBundle", "(", ")", ";", "$", "this", "->", "displayCountries", "[", "$", "locale", "]", "=", "$", "regionBundle", "->", "getCountryNames", "(", "$", "locale", ")", ";", "}" ]
Loads countries in. @param string $locale
[ "Loads", "countries", "in", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Provider/CountryNameProvider.php#L77-L82
34,363
usemarkup/addressing
Provider/IntlAddressHandlebarsTemplateProvider.php
IntlAddressHandlebarsTemplateProvider.getTemplateForCountry
public function getTemplateForCountry($country, $format, array $options = []) { return new HandlebarsTemplate($this->getRenderFunction(strtolower($country), $format)); }
php
public function getTemplateForCountry($country, $format, array $options = []) { return new HandlebarsTemplate($this->getRenderFunction(strtolower($country), $format)); }
[ "public", "function", "getTemplateForCountry", "(", "$", "country", ",", "$", "format", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "new", "HandlebarsTemplate", "(", "$", "this", "->", "getRenderFunction", "(", "strtolower", "(", "$", "country", ")", ",", "$", "format", ")", ")", ";", "}" ]
Gets a template that pertains to the provided country. @param string $country The ISO3166 alpha-2 value for a country (case-insensitive). @param string $format The address format being used. @param array $options @return TemplateInterface
[ "Gets", "a", "template", "that", "pertains", "to", "the", "provided", "country", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Provider/IntlAddressHandlebarsTemplateProvider.php#L53-L56
34,364
usemarkup/addressing
Geography.php
Geography.checkInEu
public function checkInEu($addressOrCountry) { $country = (is_object($addressOrCountry) && method_exists($addressOrCountry, 'getCountry')) ? $addressOrCountry->getCountry() : $addressOrCountry; if (!is_string($country)) { return false; } return in_array($country, self::$euCountries); }
php
public function checkInEu($addressOrCountry) { $country = (is_object($addressOrCountry) && method_exists($addressOrCountry, 'getCountry')) ? $addressOrCountry->getCountry() : $addressOrCountry; if (!is_string($country)) { return false; } return in_array($country, self::$euCountries); }
[ "public", "function", "checkInEu", "(", "$", "addressOrCountry", ")", "{", "$", "country", "=", "(", "is_object", "(", "$", "addressOrCountry", ")", "&&", "method_exists", "(", "$", "addressOrCountry", ",", "'getCountry'", ")", ")", "?", "$", "addressOrCountry", "->", "getCountry", "(", ")", ":", "$", "addressOrCountry", ";", "if", "(", "!", "is_string", "(", "$", "country", ")", ")", "{", "return", "false", ";", "}", "return", "in_array", "(", "$", "country", ",", "self", "::", "$", "euCountries", ")", ";", "}" ]
Gets whether the country or address are in the EU. @param mixed $addressOrCountry @return bool
[ "Gets", "whether", "the", "country", "or", "address", "are", "in", "the", "EU", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Geography.php#L104-L112
34,365
usemarkup/addressing
Geography.php
Geography.getUsStateAbbreviationForName
public function getUsStateAbbreviationForName($name) { if (!in_array($name, self::$usStates)) { return null; } return (string) array_search($name, self::$usStates); }
php
public function getUsStateAbbreviationForName($name) { if (!in_array($name, self::$usStates)) { return null; } return (string) array_search($name, self::$usStates); }
[ "public", "function", "getUsStateAbbreviationForName", "(", "$", "name", ")", "{", "if", "(", "!", "in_array", "(", "$", "name", ",", "self", "::", "$", "usStates", ")", ")", "{", "return", "null", ";", "}", "return", "(", "string", ")", "array_search", "(", "$", "name", ",", "self", "::", "$", "usStates", ")", ";", "}" ]
Gets the abbreviation for the provided state name, if this can be found - otherwise returns null. @param string $name @return string|null
[ "Gets", "the", "abbreviation", "for", "the", "provided", "state", "name", "if", "this", "can", "be", "found", "-", "otherwise", "returns", "null", "." ]
facd8fe58ba187b92e06490d8a6416999fb8f711
https://github.com/usemarkup/addressing/blob/facd8fe58ba187b92e06490d8a6416999fb8f711/Geography.php#L120-L127
34,366
epfremmer/swagger-php
src/Parser/SwaggerParser.php
SwaggerParser.getVersion
public function getVersion() { if (!array_key_exists(self::VERSION_KEY, $this->data)) { $this->data[self::VERSION_KEY] = self::MINIMUM_VERSION; } if (!version_compare($this->data[self::VERSION_KEY], SwaggerParser::MINIMUM_VERSION, '>=')) { throw new InvalidVersionException($this->data[self::VERSION_KEY]); } return $this->data[self::VERSION_KEY]; }
php
public function getVersion() { if (!array_key_exists(self::VERSION_KEY, $this->data)) { $this->data[self::VERSION_KEY] = self::MINIMUM_VERSION; } if (!version_compare($this->data[self::VERSION_KEY], SwaggerParser::MINIMUM_VERSION, '>=')) { throw new InvalidVersionException($this->data[self::VERSION_KEY]); } return $this->data[self::VERSION_KEY]; }
[ "public", "function", "getVersion", "(", ")", "{", "if", "(", "!", "array_key_exists", "(", "self", "::", "VERSION_KEY", ",", "$", "this", "->", "data", ")", ")", "{", "$", "this", "->", "data", "[", "self", "::", "VERSION_KEY", "]", "=", "self", "::", "MINIMUM_VERSION", ";", "}", "if", "(", "!", "version_compare", "(", "$", "this", "->", "data", "[", "self", "::", "VERSION_KEY", "]", ",", "SwaggerParser", "::", "MINIMUM_VERSION", ",", "'>='", ")", ")", "{", "throw", "new", "InvalidVersionException", "(", "$", "this", "->", "data", "[", "self", "::", "VERSION_KEY", "]", ")", ";", "}", "return", "$", "this", "->", "data", "[", "self", "::", "VERSION_KEY", "]", ";", "}" ]
Return swagger version @return string
[ "Return", "swagger", "version" ]
9915e610f8da8b1d50895941498a5c2904e96aa3
https://github.com/epfremmer/swagger-php/blob/9915e610f8da8b1d50895941498a5c2904e96aa3/src/Parser/SwaggerParser.php#L35-L46
34,367
epfremmer/swagger-php
src/Parser/FileParser.php
FileParser.parse
protected function parse($file) { $data = json_decode(file_get_contents($file), true) ?: Yaml::parse(file_get_contents($file)); return $data; }
php
protected function parse($file) { $data = json_decode(file_get_contents($file), true) ?: Yaml::parse(file_get_contents($file)); return $data; }
[ "protected", "function", "parse", "(", "$", "file", ")", "{", "$", "data", "=", "json_decode", "(", "file_get_contents", "(", "$", "file", ")", ",", "true", ")", "?", ":", "Yaml", "::", "parse", "(", "file_get_contents", "(", "$", "file", ")", ")", ";", "return", "$", "data", ";", "}" ]
Parse the swagger file @param string $file - fully qualified file path @return array
[ "Parse", "the", "swagger", "file" ]
9915e610f8da8b1d50895941498a5c2904e96aa3
https://github.com/epfremmer/swagger-php/blob/9915e610f8da8b1d50895941498a5c2904e96aa3/src/Parser/FileParser.php#L34-L39
34,368
epfremmer/swagger-php
src/Annotations/Discriminator.php
Discriminator.getClass
public function getClass(array $data) { if (!array_key_exists($this->field, $data)) { return $this->map[$this->getDefault()]; } $type = $data[$this->field]; // fallback to default if type not found in map if (!isset($this->map[$type])) { $type = $this->getDefault(); } return $this->map[$type]; }
php
public function getClass(array $data) { if (!array_key_exists($this->field, $data)) { return $this->map[$this->getDefault()]; } $type = $data[$this->field]; // fallback to default if type not found in map if (!isset($this->map[$type])) { $type = $this->getDefault(); } return $this->map[$type]; }
[ "public", "function", "getClass", "(", "array", "$", "data", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "field", ",", "$", "data", ")", ")", "{", "return", "$", "this", "->", "map", "[", "$", "this", "->", "getDefault", "(", ")", "]", ";", "}", "$", "type", "=", "$", "data", "[", "$", "this", "->", "field", "]", ";", "// fallback to default if type not found in map", "if", "(", "!", "isset", "(", "$", "this", "->", "map", "[", "$", "type", "]", ")", ")", "{", "$", "type", "=", "$", "this", "->", "getDefault", "(", ")", ";", "}", "return", "$", "this", "->", "map", "[", "$", "type", "]", ";", "}" ]
Return the correct mapped class @param array $data @return mixed
[ "Return", "the", "correct", "mapped", "class" ]
9915e610f8da8b1d50895941498a5c2904e96aa3
https://github.com/epfremmer/swagger-php/blob/9915e610f8da8b1d50895941498a5c2904e96aa3/src/Annotations/Discriminator.php#L58-L72
34,369
epfremmer/swagger-php
src/Factory/SwaggerFactory.php
SwaggerFactory.serialize
public function serialize(Swagger $swagger) { $context = new SerializationContext(); $context->setVersion( $swagger->getVersion() ); return $this->serializer->serialize($swagger, 'json', $context); }
php
public function serialize(Swagger $swagger) { $context = new SerializationContext(); $context->setVersion( $swagger->getVersion() ); return $this->serializer->serialize($swagger, 'json', $context); }
[ "public", "function", "serialize", "(", "Swagger", "$", "swagger", ")", "{", "$", "context", "=", "new", "SerializationContext", "(", ")", ";", "$", "context", "->", "setVersion", "(", "$", "swagger", "->", "getVersion", "(", ")", ")", ";", "return", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "swagger", ",", "'json'", ",", "$", "context", ")", ";", "}" ]
Return serialized Swagger document @param Swagger $swagger @return string
[ "Return", "serialized", "Swagger", "document" ]
9915e610f8da8b1d50895941498a5c2904e96aa3
https://github.com/epfremmer/swagger-php/blob/9915e610f8da8b1d50895941498a5c2904e96aa3/src/Factory/SwaggerFactory.php#L89-L98
34,370
epfremmer/swagger-php
src/Factory/SwaggerFactory.php
SwaggerFactory.buildFromParser
private function buildFromParser(SwaggerParser $parser) { $context = new DeserializationContext(); $context->setVersion( $parser->getVersion() ); return $this->serializer->deserialize($parser, Swagger::class, 'json', $context); }
php
private function buildFromParser(SwaggerParser $parser) { $context = new DeserializationContext(); $context->setVersion( $parser->getVersion() ); return $this->serializer->deserialize($parser, Swagger::class, 'json', $context); }
[ "private", "function", "buildFromParser", "(", "SwaggerParser", "$", "parser", ")", "{", "$", "context", "=", "new", "DeserializationContext", "(", ")", ";", "$", "context", "->", "setVersion", "(", "$", "parser", "->", "getVersion", "(", ")", ")", ";", "return", "$", "this", "->", "serializer", "->", "deserialize", "(", "$", "parser", ",", "Swagger", "::", "class", ",", "'json'", ",", "$", "context", ")", ";", "}" ]
Return de-serialized Swagger result @param SwaggerParser $parser @return Swagger @throws \LogicException
[ "Return", "de", "-", "serialized", "Swagger", "result" ]
9915e610f8da8b1d50895941498a5c2904e96aa3
https://github.com/epfremmer/swagger-php/blob/9915e610f8da8b1d50895941498a5c2904e96aa3/src/Factory/SwaggerFactory.php#L107-L116
34,371
epfremmer/swagger-php
src/Listener/SerializationSubscriber.php
SerializationSubscriber.onPreDeserialize
public function onPreDeserialize(PreDeserializeEvent $event) { $class = $event->getType()['name']; if (!class_exists($class)) { return; // skip custom JMS types } $data = $event->getData(); $object = new \ReflectionClass($class); $discriminator = $this->reader->getClassAnnotation($object, Discriminator::class); if ($discriminator) { $event->setType($discriminator->getClass($data)); } }
php
public function onPreDeserialize(PreDeserializeEvent $event) { $class = $event->getType()['name']; if (!class_exists($class)) { return; // skip custom JMS types } $data = $event->getData(); $object = new \ReflectionClass($class); $discriminator = $this->reader->getClassAnnotation($object, Discriminator::class); if ($discriminator) { $event->setType($discriminator->getClass($data)); } }
[ "public", "function", "onPreDeserialize", "(", "PreDeserializeEvent", "$", "event", ")", "{", "$", "class", "=", "$", "event", "->", "getType", "(", ")", "[", "'name'", "]", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "return", ";", "// skip custom JMS types", "}", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";", "$", "object", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "discriminator", "=", "$", "this", "->", "reader", "->", "getClassAnnotation", "(", "$", "object", ",", "Discriminator", "::", "class", ")", ";", "if", "(", "$", "discriminator", ")", "{", "$", "event", "->", "setType", "(", "$", "discriminator", "->", "getClass", "(", "$", "data", ")", ")", ";", "}", "}" ]
Checks for the existence of a discriminator annotation and sets the corresponding mapped deserialization class @param PreDeserializeEvent $event
[ "Checks", "for", "the", "existence", "of", "a", "discriminator", "annotation", "and", "sets", "the", "corresponding", "mapped", "deserialization", "class" ]
9915e610f8da8b1d50895941498a5c2904e96aa3
https://github.com/epfremmer/swagger-php/blob/9915e610f8da8b1d50895941498a5c2904e96aa3/src/Listener/SerializationSubscriber.php#L89-L105
34,372
epfremmer/swagger-php
src/Listener/SerializationSubscriber.php
SerializationSubscriber.onParameterPreDeserialize
public function onParameterPreDeserialize(PreDeserializeEvent $event) { $data = $event->getData(); if (array_key_exists('$ref', $data)) { $event->setType(RefParameter::class); return; } $data['class'] = $data['in']; if (array_key_exists('type', $data)) { $data['class'] = sprintf('%s.%s', $data['in'], $data['type']); } $event->setData($data); }
php
public function onParameterPreDeserialize(PreDeserializeEvent $event) { $data = $event->getData(); if (array_key_exists('$ref', $data)) { $event->setType(RefParameter::class); return; } $data['class'] = $data['in']; if (array_key_exists('type', $data)) { $data['class'] = sprintf('%s.%s', $data['in'], $data['type']); } $event->setData($data); }
[ "public", "function", "onParameterPreDeserialize", "(", "PreDeserializeEvent", "$", "event", ")", "{", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";", "if", "(", "array_key_exists", "(", "'$ref'", ",", "$", "data", ")", ")", "{", "$", "event", "->", "setType", "(", "RefParameter", "::", "class", ")", ";", "return", ";", "}", "$", "data", "[", "'class'", "]", "=", "$", "data", "[", "'in'", "]", ";", "if", "(", "array_key_exists", "(", "'type'", ",", "$", "data", ")", ")", "{", "$", "data", "[", "'class'", "]", "=", "sprintf", "(", "'%s.%s'", ",", "$", "data", "[", "'in'", "]", ",", "$", "data", "[", "'type'", "]", ")", ";", "}", "$", "event", "->", "setData", "(", "$", "data", ")", ";", "}" ]
Set custom composite discriminator key based on multiple parameter fields before deserialization to ensure proper discrimination mapping @param PreDeserializeEvent $event
[ "Set", "custom", "composite", "discriminator", "key", "based", "on", "multiple", "parameter", "fields", "before", "deserialization", "to", "ensure", "proper", "discrimination", "mapping" ]
9915e610f8da8b1d50895941498a5c2904e96aa3
https://github.com/epfremmer/swagger-php/blob/9915e610f8da8b1d50895941498a5c2904e96aa3/src/Listener/SerializationSubscriber.php#L135-L151
34,373
KnpLabs/mailjet-api-php
src/Mailjet/Api/Client.php
Client.post
public function post($apiQuery, $options = array()) { if (!RequestApi::isPost($apiQuery)) { throw new \InvalidArgumentException('Unsupported API query for POST method: ' . $apiQuery); } $request = $this->getApi()->post($apiQuery, null, $options); $this->prepareRequest($request, $options); $response = $request->send(); return $this->processResponse($response); }
php
public function post($apiQuery, $options = array()) { if (!RequestApi::isPost($apiQuery)) { throw new \InvalidArgumentException('Unsupported API query for POST method: ' . $apiQuery); } $request = $this->getApi()->post($apiQuery, null, $options); $this->prepareRequest($request, $options); $response = $request->send(); return $this->processResponse($response); }
[ "public", "function", "post", "(", "$", "apiQuery", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "!", "RequestApi", "::", "isPost", "(", "$", "apiQuery", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unsupported API query for POST method: '", ".", "$", "apiQuery", ")", ";", "}", "$", "request", "=", "$", "this", "->", "getApi", "(", ")", "->", "post", "(", "$", "apiQuery", ",", "null", ",", "$", "options", ")", ";", "$", "this", "->", "prepareRequest", "(", "$", "request", ",", "$", "options", ")", ";", "$", "response", "=", "$", "request", "->", "send", "(", ")", ";", "return", "$", "this", "->", "processResponse", "(", "$", "response", ")", ";", "}" ]
Method for issuing low level API POST requests @see Client::get()
[ "Method", "for", "issuing", "low", "level", "API", "POST", "requests" ]
042968e4c516845248323c8db367cdb033329ae4
https://github.com/KnpLabs/mailjet-api-php/blob/042968e4c516845248323c8db367cdb033329ae4/src/Mailjet/Api/Client.php#L64-L77
34,374
M6Web/ElasticsearchBundle
src/M6Web/Bundle/ElasticsearchBundle/Elasticsearch/ConnectionPool/StaticAliveNoPingConnectionPool.php
StaticAliveNoPingConnectionPool.readyToRevive
protected function readyToRevive(Connection $connection) { $timeout = min( $this->pingTimeout * pow(2, $connection->getPingFailures()), $this->maxPingTimeout ); if ($connection->getLastPing() + $timeout < time()) { return true; } else { return false; } }
php
protected function readyToRevive(Connection $connection) { $timeout = min( $this->pingTimeout * pow(2, $connection->getPingFailures()), $this->maxPingTimeout ); if ($connection->getLastPing() + $timeout < time()) { return true; } else { return false; } }
[ "protected", "function", "readyToRevive", "(", "Connection", "$", "connection", ")", "{", "$", "timeout", "=", "min", "(", "$", "this", "->", "pingTimeout", "*", "pow", "(", "2", ",", "$", "connection", "->", "getPingFailures", "(", ")", ")", ",", "$", "this", "->", "maxPingTimeout", ")", ";", "if", "(", "$", "connection", "->", "getLastPing", "(", ")", "+", "$", "timeout", "<", "time", "(", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
> Same as parent private method. @param Connection $connection @return bool
[ ">", "Same", "as", "parent", "private", "method", "." ]
0f9bcba0bea85a359aa43bebbb777a5badf08b16
https://github.com/M6Web/ElasticsearchBundle/blob/0f9bcba0bea85a359aa43bebbb777a5badf08b16/src/M6Web/Bundle/ElasticsearchBundle/Elasticsearch/ConnectionPool/StaticAliveNoPingConnectionPool.php#L90-L102
34,375
M6Web/ElasticsearchBundle
src/M6Web/Bundle/ElasticsearchBundle/Handler/EventHandler.php
EventHandler.extractTookFromResponse
protected function extractTookFromResponse(array $response) { if (is_null($response['body'])) { return null; } $content = stream_get_contents($response['body']); rewind($response['body']); if (preg_match('/\"took\":(\d+)/', $content, $matches)) { return (int) $matches[1]; } return null; }
php
protected function extractTookFromResponse(array $response) { if (is_null($response['body'])) { return null; } $content = stream_get_contents($response['body']); rewind($response['body']); if (preg_match('/\"took\":(\d+)/', $content, $matches)) { return (int) $matches[1]; } return null; }
[ "protected", "function", "extractTookFromResponse", "(", "array", "$", "response", ")", "{", "if", "(", "is_null", "(", "$", "response", "[", "'body'", "]", ")", ")", "{", "return", "null", ";", "}", "$", "content", "=", "stream_get_contents", "(", "$", "response", "[", "'body'", "]", ")", ";", "rewind", "(", "$", "response", "[", "'body'", "]", ")", ";", "if", "(", "preg_match", "(", "'/\\\"took\\\":(\\d+)/'", ",", "$", "content", ",", "$", "matches", ")", ")", "{", "return", "(", "int", ")", "$", "matches", "[", "1", "]", ";", "}", "return", "null", ";", "}" ]
Extract took from response @param array $response @return int|null
[ "Extract", "took", "from", "response" ]
0f9bcba0bea85a359aa43bebbb777a5badf08b16
https://github.com/M6Web/ElasticsearchBundle/blob/0f9bcba0bea85a359aa43bebbb777a5badf08b16/src/M6Web/Bundle/ElasticsearchBundle/Handler/EventHandler.php#L90-L103
34,376
M6Web/ElasticsearchBundle
src/M6Web/Bundle/ElasticsearchBundle/DependencyInjection/M6WebElasticsearchExtension.php
M6WebElasticsearchExtension.createElasticsearchClient
protected function createElasticsearchClient(ContainerBuilder $container, $name, $config) { $definitionId = 'm6web_elasticsearch.client.'.$name; $handlerId = $this->createHandler($container, $config, $definitionId); $clientConfig = [ 'hosts' => $config['hosts'], 'handler' => new Reference($handlerId), ]; if (isset($config['retries'])) { $clientConfig['retries'] = $config['retries']; } if (isset($config['logger'])) { $clientConfig['logger'] = new Reference($config['logger']); } if (!empty($config['connectionPoolClass'])) { $clientConfig['connectionPool'] = $config['connectionPoolClass']; } if (!empty($config['selectorClass'])) { $clientConfig['selector'] = $config['selectorClass']; } if (!empty($config['connectionParams'])) { $clientConfig['connectionParams'] = $config['connectionParams']; } $definition = (new Definition($config['client_class'])) ->setArguments([$clientConfig]); $this->setFactoryToDefinition($config['clientBuilderClass'], 'fromConfig', $definition); $container->setDefinition($definitionId, $definition); if ($container->getParameter('kernel.debug')) { $this->createDataCollector($container); } }
php
protected function createElasticsearchClient(ContainerBuilder $container, $name, $config) { $definitionId = 'm6web_elasticsearch.client.'.$name; $handlerId = $this->createHandler($container, $config, $definitionId); $clientConfig = [ 'hosts' => $config['hosts'], 'handler' => new Reference($handlerId), ]; if (isset($config['retries'])) { $clientConfig['retries'] = $config['retries']; } if (isset($config['logger'])) { $clientConfig['logger'] = new Reference($config['logger']); } if (!empty($config['connectionPoolClass'])) { $clientConfig['connectionPool'] = $config['connectionPoolClass']; } if (!empty($config['selectorClass'])) { $clientConfig['selector'] = $config['selectorClass']; } if (!empty($config['connectionParams'])) { $clientConfig['connectionParams'] = $config['connectionParams']; } $definition = (new Definition($config['client_class'])) ->setArguments([$clientConfig]); $this->setFactoryToDefinition($config['clientBuilderClass'], 'fromConfig', $definition); $container->setDefinition($definitionId, $definition); if ($container->getParameter('kernel.debug')) { $this->createDataCollector($container); } }
[ "protected", "function", "createElasticsearchClient", "(", "ContainerBuilder", "$", "container", ",", "$", "name", ",", "$", "config", ")", "{", "$", "definitionId", "=", "'m6web_elasticsearch.client.'", ".", "$", "name", ";", "$", "handlerId", "=", "$", "this", "->", "createHandler", "(", "$", "container", ",", "$", "config", ",", "$", "definitionId", ")", ";", "$", "clientConfig", "=", "[", "'hosts'", "=>", "$", "config", "[", "'hosts'", "]", ",", "'handler'", "=>", "new", "Reference", "(", "$", "handlerId", ")", ",", "]", ";", "if", "(", "isset", "(", "$", "config", "[", "'retries'", "]", ")", ")", "{", "$", "clientConfig", "[", "'retries'", "]", "=", "$", "config", "[", "'retries'", "]", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'logger'", "]", ")", ")", "{", "$", "clientConfig", "[", "'logger'", "]", "=", "new", "Reference", "(", "$", "config", "[", "'logger'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'connectionPoolClass'", "]", ")", ")", "{", "$", "clientConfig", "[", "'connectionPool'", "]", "=", "$", "config", "[", "'connectionPoolClass'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'selectorClass'", "]", ")", ")", "{", "$", "clientConfig", "[", "'selector'", "]", "=", "$", "config", "[", "'selectorClass'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'connectionParams'", "]", ")", ")", "{", "$", "clientConfig", "[", "'connectionParams'", "]", "=", "$", "config", "[", "'connectionParams'", "]", ";", "}", "$", "definition", "=", "(", "new", "Definition", "(", "$", "config", "[", "'client_class'", "]", ")", ")", "->", "setArguments", "(", "[", "$", "clientConfig", "]", ")", ";", "$", "this", "->", "setFactoryToDefinition", "(", "$", "config", "[", "'clientBuilderClass'", "]", ",", "'fromConfig'", ",", "$", "definition", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "definitionId", ",", "$", "definition", ")", ";", "if", "(", "$", "container", "->", "getParameter", "(", "'kernel.debug'", ")", ")", "{", "$", "this", "->", "createDataCollector", "(", "$", "container", ")", ";", "}", "}" ]
Add a new Elasticsearch client definition in the container @param ContainerBuilder $container @param string $name @param array $config
[ "Add", "a", "new", "Elasticsearch", "client", "definition", "in", "the", "container" ]
0f9bcba0bea85a359aa43bebbb777a5badf08b16
https://github.com/M6Web/ElasticsearchBundle/blob/0f9bcba0bea85a359aa43bebbb777a5badf08b16/src/M6Web/Bundle/ElasticsearchBundle/DependencyInjection/M6WebElasticsearchExtension.php#L59-L99
34,377
M6Web/ElasticsearchBundle
src/M6Web/Bundle/ElasticsearchBundle/DependencyInjection/M6WebElasticsearchExtension.php
M6WebElasticsearchExtension.createHandler
protected function createHandler(ContainerBuilder $container, array $config, $definitionId) { // cURL handler $singleHandler = (new Definition('GuzzleHttp\Ring\Client\CurlHandler')) ->setPublic(false); $this->setFactoryToDefinition('Elasticsearch\ClientBuilder', 'defaultHandler', $singleHandler); $singleHandlerId = $definitionId.'.single_handler'; $container->setDefinition($singleHandlerId, $singleHandler); // Headers handler $headersHandler = (new Definition('M6Web\Bundle\ElasticsearchBundle\Handler\HeadersHandler')) ->setPublic(false) ->setArguments([new Reference($singleHandlerId)]); if (isset($config['headers'])) { foreach ($config['headers'] as $key => $value) { $headersHandler->addMethodCall('setHeader', [$key, $value]); } } $headersHandlerId = $definitionId.'.headers_handler'; $container->setDefinition($headersHandlerId, $headersHandler); // Event handler $eventHandler = (new Definition('M6Web\Bundle\ElasticsearchBundle\Handler\EventHandler')) ->setPublic(false) ->setArguments([new Reference('event_dispatcher'), new Reference($headersHandlerId)]); $eventHandlerId = $definitionId.'.event_handler'; $container->setDefinition($eventHandlerId, $eventHandler); return $eventHandlerId; }
php
protected function createHandler(ContainerBuilder $container, array $config, $definitionId) { // cURL handler $singleHandler = (new Definition('GuzzleHttp\Ring\Client\CurlHandler')) ->setPublic(false); $this->setFactoryToDefinition('Elasticsearch\ClientBuilder', 'defaultHandler', $singleHandler); $singleHandlerId = $definitionId.'.single_handler'; $container->setDefinition($singleHandlerId, $singleHandler); // Headers handler $headersHandler = (new Definition('M6Web\Bundle\ElasticsearchBundle\Handler\HeadersHandler')) ->setPublic(false) ->setArguments([new Reference($singleHandlerId)]); if (isset($config['headers'])) { foreach ($config['headers'] as $key => $value) { $headersHandler->addMethodCall('setHeader', [$key, $value]); } } $headersHandlerId = $definitionId.'.headers_handler'; $container->setDefinition($headersHandlerId, $headersHandler); // Event handler $eventHandler = (new Definition('M6Web\Bundle\ElasticsearchBundle\Handler\EventHandler')) ->setPublic(false) ->setArguments([new Reference('event_dispatcher'), new Reference($headersHandlerId)]); $eventHandlerId = $definitionId.'.event_handler'; $container->setDefinition($eventHandlerId, $eventHandler); return $eventHandlerId; }
[ "protected", "function", "createHandler", "(", "ContainerBuilder", "$", "container", ",", "array", "$", "config", ",", "$", "definitionId", ")", "{", "// cURL handler", "$", "singleHandler", "=", "(", "new", "Definition", "(", "'GuzzleHttp\\Ring\\Client\\CurlHandler'", ")", ")", "->", "setPublic", "(", "false", ")", ";", "$", "this", "->", "setFactoryToDefinition", "(", "'Elasticsearch\\ClientBuilder'", ",", "'defaultHandler'", ",", "$", "singleHandler", ")", ";", "$", "singleHandlerId", "=", "$", "definitionId", ".", "'.single_handler'", ";", "$", "container", "->", "setDefinition", "(", "$", "singleHandlerId", ",", "$", "singleHandler", ")", ";", "// Headers handler", "$", "headersHandler", "=", "(", "new", "Definition", "(", "'M6Web\\Bundle\\ElasticsearchBundle\\Handler\\HeadersHandler'", ")", ")", "->", "setPublic", "(", "false", ")", "->", "setArguments", "(", "[", "new", "Reference", "(", "$", "singleHandlerId", ")", "]", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'headers'", "]", ")", ")", "{", "foreach", "(", "$", "config", "[", "'headers'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "headersHandler", "->", "addMethodCall", "(", "'setHeader'", ",", "[", "$", "key", ",", "$", "value", "]", ")", ";", "}", "}", "$", "headersHandlerId", "=", "$", "definitionId", ".", "'.headers_handler'", ";", "$", "container", "->", "setDefinition", "(", "$", "headersHandlerId", ",", "$", "headersHandler", ")", ";", "// Event handler", "$", "eventHandler", "=", "(", "new", "Definition", "(", "'M6Web\\Bundle\\ElasticsearchBundle\\Handler\\EventHandler'", ")", ")", "->", "setPublic", "(", "false", ")", "->", "setArguments", "(", "[", "new", "Reference", "(", "'event_dispatcher'", ")", ",", "new", "Reference", "(", "$", "headersHandlerId", ")", "]", ")", ";", "$", "eventHandlerId", "=", "$", "definitionId", ".", "'.event_handler'", ";", "$", "container", "->", "setDefinition", "(", "$", "eventHandlerId", ",", "$", "eventHandler", ")", ";", "return", "$", "eventHandlerId", ";", "}" ]
Create request handler @param ContainerBuilder $container @param array $config @param string $definitionId @return string
[ "Create", "request", "handler" ]
0f9bcba0bea85a359aa43bebbb777a5badf08b16
https://github.com/M6Web/ElasticsearchBundle/blob/0f9bcba0bea85a359aa43bebbb777a5badf08b16/src/M6Web/Bundle/ElasticsearchBundle/DependencyInjection/M6WebElasticsearchExtension.php#L110-L141
34,378
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Type/Collection.php
Collection.add
public function add($type) { if (!is_string($type)) { throw new \InvalidArgumentException( 'A type should be represented by a string, received: ' .var_export($type, true) ); } // separate the type by the OR operator $type_parts = explode(self::OPERATOR_OR, $type); foreach ($type_parts as $part) { $expanded_type = $this->expand($part); if ($expanded_type) { $this[] = $expanded_type; } } }
php
public function add($type) { if (!is_string($type)) { throw new \InvalidArgumentException( 'A type should be represented by a string, received: ' .var_export($type, true) ); } // separate the type by the OR operator $type_parts = explode(self::OPERATOR_OR, $type); foreach ($type_parts as $part) { $expanded_type = $this->expand($part); if ($expanded_type) { $this[] = $expanded_type; } } }
[ "public", "function", "add", "(", "$", "type", ")", "{", "if", "(", "!", "is_string", "(", "$", "type", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A type should be represented by a string, received: '", ".", "var_export", "(", "$", "type", ",", "true", ")", ")", ";", "}", "// separate the type by the OR operator", "$", "type_parts", "=", "explode", "(", "self", "::", "OPERATOR_OR", ",", "$", "type", ")", ";", "foreach", "(", "$", "type_parts", "as", "$", "part", ")", "{", "$", "expanded_type", "=", "$", "this", "->", "expand", "(", "$", "part", ")", ";", "if", "(", "$", "expanded_type", ")", "{", "$", "this", "[", "]", "=", "$", "expanded_type", ";", "}", "}", "}" ]
Adds a new type to the collection and expands it if it contains a relative namespace. If a class in the type contains a relative namespace than this collection will try to expand that into a FQCN. @param string $type A 'Type' as defined in the phpDocumentor documentation. @throws \InvalidArgumentException if a non-string argument is passed. @see http://phpdoc.org/docs/latest/for-users/types.html for the definition of a type. @return void
[ "Adds", "a", "new", "type", "to", "the", "collection", "and", "expands", "it", "if", "it", "contains", "a", "relative", "namespace", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Type/Collection.php#L99-L116
34,379
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Serializer.php
Serializer.setLineLength
public function setLineLength($lineLength) { $this->lineLength = null === $lineLength ? null : (int)$lineLength; return $this; }
php
public function setLineLength($lineLength) { $this->lineLength = null === $lineLength ? null : (int)$lineLength; return $this; }
[ "public", "function", "setLineLength", "(", "$", "lineLength", ")", "{", "$", "this", "->", "lineLength", "=", "null", "===", "$", "lineLength", "?", "null", ":", "(", "int", ")", "$", "lineLength", ";", "return", "$", "this", ";", "}" ]
Sets the line length. Sets the length of each line in the serialization. Content will be wrapped within this limit. @param int|null $lineLength The length of each line. NULL to disable line wrapping altogether. @return $this This serializer object.
[ "Sets", "the", "line", "length", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Serializer.php#L144-L148
34,380
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Context.php
Context.setNamespaceAliases
public function setNamespaceAliases(array $namespace_aliases) { $this->namespace_aliases = array(); foreach ($namespace_aliases as $alias => $fqnn) { $this->setNamespaceAlias($alias, $fqnn); } return $this; }
php
public function setNamespaceAliases(array $namespace_aliases) { $this->namespace_aliases = array(); foreach ($namespace_aliases as $alias => $fqnn) { $this->setNamespaceAlias($alias, $fqnn); } return $this; }
[ "public", "function", "setNamespaceAliases", "(", "array", "$", "namespace_aliases", ")", "{", "$", "this", "->", "namespace_aliases", "=", "array", "(", ")", ";", "foreach", "(", "$", "namespace_aliases", "as", "$", "alias", "=>", "$", "fqnn", ")", "{", "$", "this", "->", "setNamespaceAlias", "(", "$", "alias", ",", "$", "fqnn", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the namespace aliases, replacing all previous ones. @param array $namespace_aliases List of namespace aliases => Fully Qualified Namespace. @return $this
[ "Sets", "the", "namespace", "aliases", "replacing", "all", "previous", "ones", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Context.php#L112-L119
34,381
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Context.php
Context.setNamespaceAlias
public function setNamespaceAlias($alias, $fqnn) { $this->namespace_aliases[$alias] = '\\' . trim((string)$fqnn, '\\'); return $this; }
php
public function setNamespaceAlias($alias, $fqnn) { $this->namespace_aliases[$alias] = '\\' . trim((string)$fqnn, '\\'); return $this; }
[ "public", "function", "setNamespaceAlias", "(", "$", "alias", ",", "$", "fqnn", ")", "{", "$", "this", "->", "namespace_aliases", "[", "$", "alias", "]", "=", "'\\\\'", ".", "trim", "(", "(", "string", ")", "$", "fqnn", ",", "'\\\\'", ")", ";", "return", "$", "this", ";", "}" ]
Adds a namespace alias to the context. @param string $alias The alias name (the part after "as", or the last part of the Fully Qualified Namespace Name) to add. @param string $fqnn The Fully Qualified Namespace Name for this alias. Any form of leading/trailing slashes are accepted, but what will be stored is a name, prefixed with a slash, and no trailing slash. @return $this
[ "Adds", "a", "namespace", "alias", "to", "the", "context", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Context.php#L132-L136
34,382
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock.php
DocBlock.getText
public function getText() { $short = $this->getShortDescription(); $long = $this->getLongDescription()->getContents(); if ($long) { return "{$short}\n\n{$long}"; } else { return $short; } }
php
public function getText() { $short = $this->getShortDescription(); $long = $this->getLongDescription()->getContents(); if ($long) { return "{$short}\n\n{$long}"; } else { return $short; } }
[ "public", "function", "getText", "(", ")", "{", "$", "short", "=", "$", "this", "->", "getShortDescription", "(", ")", ";", "$", "long", "=", "$", "this", "->", "getLongDescription", "(", ")", "->", "getContents", "(", ")", ";", "if", "(", "$", "long", ")", "{", "return", "\"{$short}\\n\\n{$long}\"", ";", "}", "else", "{", "return", "$", "short", ";", "}", "}" ]
Gets the text portion of the doc block. Gets the text portion (short and long description combined) of the doc block. @return string The text portion of the doc block.
[ "Gets", "the", "text", "portion", "of", "the", "doc", "block", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock.php#L256-L266
34,383
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock.php
DocBlock.setText
public function setText($comment) { list(,$short, $long) = $this->splitDocBlock($comment); $this->short_description = $short; $this->long_description = new DocBlock\Description($long, $this); return $this; }
php
public function setText($comment) { list(,$short, $long) = $this->splitDocBlock($comment); $this->short_description = $short; $this->long_description = new DocBlock\Description($long, $this); return $this; }
[ "public", "function", "setText", "(", "$", "comment", ")", "{", "list", "(", ",", "$", "short", ",", "$", "long", ")", "=", "$", "this", "->", "splitDocBlock", "(", "$", "comment", ")", ";", "$", "this", "->", "short_description", "=", "$", "short", ";", "$", "this", "->", "long_description", "=", "new", "DocBlock", "\\", "Description", "(", "$", "long", ",", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Set the text portion of the doc block. Sets the text portion (short and long description combined) of the doc block. @param string $docblock The new text portion of the doc block. @return $this This doc block.
[ "Set", "the", "text", "portion", "of", "the", "doc", "block", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock.php#L278-L284
34,384
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock.php
DocBlock.appendTag
public function appendTag(Tag $tag) { if (null === $tag->getDocBlock()) { $tag->setDocBlock($this); } if ($tag->getDocBlock() === $this) { $this->tags[] = $tag; } else { throw new \LogicException( 'This tag belongs to a different DocBlock object.' ); } return $tag; }
php
public function appendTag(Tag $tag) { if (null === $tag->getDocBlock()) { $tag->setDocBlock($this); } if ($tag->getDocBlock() === $this) { $this->tags[] = $tag; } else { throw new \LogicException( 'This tag belongs to a different DocBlock object.' ); } return $tag; }
[ "public", "function", "appendTag", "(", "Tag", "$", "tag", ")", "{", "if", "(", "null", "===", "$", "tag", "->", "getDocBlock", "(", ")", ")", "{", "$", "tag", "->", "setDocBlock", "(", "$", "this", ")", ";", "}", "if", "(", "$", "tag", "->", "getDocBlock", "(", ")", "===", "$", "this", ")", "{", "$", "this", "->", "tags", "[", "]", "=", "$", "tag", ";", "}", "else", "{", "throw", "new", "\\", "LogicException", "(", "'This tag belongs to a different DocBlock object.'", ")", ";", "}", "return", "$", "tag", ";", "}" ]
Appends a tag at the end of the list of tags. @param Tag $tag The tag to add. @return Tag The newly added tag. @throws \LogicException When the tag belongs to a different DocBlock.
[ "Appends", "a", "tag", "at", "the", "end", "of", "the", "list", "of", "tags", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock.php#L425-L440
34,385
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Description.php
Description.setContent
public function setContent($content) { $this->contents = trim($content); $this->parsedContents = null; return $this; }
php
public function setContent($content) { $this->contents = trim($content); $this->parsedContents = null; return $this; }
[ "public", "function", "setContent", "(", "$", "content", ")", "{", "$", "this", "->", "contents", "=", "trim", "(", "$", "content", ")", ";", "$", "this", "->", "parsedContents", "=", "null", ";", "return", "$", "this", ";", "}" ]
Sets the text of this description. @param string $content The new text of this description. @return $this
[ "Sets", "the", "text", "of", "this", "description", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Description.php#L63-L69
34,386
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Description.php
Description.getFormattedContents
public function getFormattedContents() { $result = $this->contents; // if the long description contains a plain HTML <code> element, surround // it with a pre element. Please note that we explicitly used str_replace // and not preg_replace to gain performance if (strpos($result, '<code>') !== false) { $result = str_replace( array('<code>', "<code>\r\n", "<code>\n", "<code>\r", '</code>'), array('<pre><code>', '<code>', '<code>', '<code>', '</code></pre>'), $result ); } if (class_exists('Parsedown')) { $markdown = \Parsedown::instance(); $result = $markdown->parse($result); } elseif (class_exists('dflydev\markdown\MarkdownExtraParser')) { $markdown = new \dflydev\markdown\MarkdownExtraParser(); $result = $markdown->transformMarkdown($result); } return trim($result); }
php
public function getFormattedContents() { $result = $this->contents; // if the long description contains a plain HTML <code> element, surround // it with a pre element. Please note that we explicitly used str_replace // and not preg_replace to gain performance if (strpos($result, '<code>') !== false) { $result = str_replace( array('<code>', "<code>\r\n", "<code>\n", "<code>\r", '</code>'), array('<pre><code>', '<code>', '<code>', '<code>', '</code></pre>'), $result ); } if (class_exists('Parsedown')) { $markdown = \Parsedown::instance(); $result = $markdown->parse($result); } elseif (class_exists('dflydev\markdown\MarkdownExtraParser')) { $markdown = new \dflydev\markdown\MarkdownExtraParser(); $result = $markdown->transformMarkdown($result); } return trim($result); }
[ "public", "function", "getFormattedContents", "(", ")", "{", "$", "result", "=", "$", "this", "->", "contents", ";", "// if the long description contains a plain HTML <code> element, surround", "// it with a pre element. Please note that we explicitly used str_replace", "// and not preg_replace to gain performance", "if", "(", "strpos", "(", "$", "result", ",", "'<code>'", ")", "!==", "false", ")", "{", "$", "result", "=", "str_replace", "(", "array", "(", "'<code>'", ",", "\"<code>\\r\\n\"", ",", "\"<code>\\n\"", ",", "\"<code>\\r\"", ",", "'</code>'", ")", ",", "array", "(", "'<pre><code>'", ",", "'<code>'", ",", "'<code>'", ",", "'<code>'", ",", "'</code></pre>'", ")", ",", "$", "result", ")", ";", "}", "if", "(", "class_exists", "(", "'Parsedown'", ")", ")", "{", "$", "markdown", "=", "\\", "Parsedown", "::", "instance", "(", ")", ";", "$", "result", "=", "$", "markdown", "->", "parse", "(", "$", "result", ")", ";", "}", "elseif", "(", "class_exists", "(", "'dflydev\\markdown\\MarkdownExtraParser'", ")", ")", "{", "$", "markdown", "=", "new", "\\", "dflydev", "\\", "markdown", "\\", "MarkdownExtraParser", "(", ")", ";", "$", "result", "=", "$", "markdown", "->", "transformMarkdown", "(", "$", "result", ")", ";", "}", "return", "trim", "(", "$", "result", ")", ";", "}" ]
Return a formatted variant of the Long Description using MarkDown. @todo this should become a more intelligent piece of code where the configuration contains a setting what format long descriptions are. @codeCoverageIgnore Will be removed soon, in favor of adapters at PhpDocumentor itself that will process text in various formats. @return string
[ "Return", "a", "formatted", "variant", "of", "the", "Long", "Description", "using", "MarkDown", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Description.php#L149-L173
34,387
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag.php
Tag.createInstance
final public static function createInstance( $tag_line, DocBlock $docblock = null, Location $location = null ) { if (!preg_match( '/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us', $tag_line, $matches )) { throw new \InvalidArgumentException( 'Invalid tag_line detected: ' . $tag_line ); } $handler = __CLASS__; if (isset(self::$tagHandlerMappings[$matches[1]])) { $handler = self::$tagHandlerMappings[$matches[1]]; } elseif (isset($docblock)) { $tagName = (string)new Type\Collection( array($matches[1]), $docblock->getContext() ); if (isset(self::$tagHandlerMappings[$tagName])) { $handler = self::$tagHandlerMappings[$tagName]; } } return new $handler( $matches[1], isset($matches[2]) ? $matches[2] : '', $docblock, $location ); }
php
final public static function createInstance( $tag_line, DocBlock $docblock = null, Location $location = null ) { if (!preg_match( '/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us', $tag_line, $matches )) { throw new \InvalidArgumentException( 'Invalid tag_line detected: ' . $tag_line ); } $handler = __CLASS__; if (isset(self::$tagHandlerMappings[$matches[1]])) { $handler = self::$tagHandlerMappings[$matches[1]]; } elseif (isset($docblock)) { $tagName = (string)new Type\Collection( array($matches[1]), $docblock->getContext() ); if (isset(self::$tagHandlerMappings[$tagName])) { $handler = self::$tagHandlerMappings[$tagName]; } } return new $handler( $matches[1], isset($matches[2]) ? $matches[2] : '', $docblock, $location ); }
[ "final", "public", "static", "function", "createInstance", "(", "$", "tag_line", ",", "DocBlock", "$", "docblock", "=", "null", ",", "Location", "$", "location", "=", "null", ")", "{", "if", "(", "!", "preg_match", "(", "'/^@('", ".", "self", "::", "REGEX_TAGNAME", ".", "')(?:\\s*([^\\s].*)|$)?/us'", ",", "$", "tag_line", ",", "$", "matches", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid tag_line detected: '", ".", "$", "tag_line", ")", ";", "}", "$", "handler", "=", "__CLASS__", ";", "if", "(", "isset", "(", "self", "::", "$", "tagHandlerMappings", "[", "$", "matches", "[", "1", "]", "]", ")", ")", "{", "$", "handler", "=", "self", "::", "$", "tagHandlerMappings", "[", "$", "matches", "[", "1", "]", "]", ";", "}", "elseif", "(", "isset", "(", "$", "docblock", ")", ")", "{", "$", "tagName", "=", "(", "string", ")", "new", "Type", "\\", "Collection", "(", "array", "(", "$", "matches", "[", "1", "]", ")", ",", "$", "docblock", "->", "getContext", "(", ")", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "tagHandlerMappings", "[", "$", "tagName", "]", ")", ")", "{", "$", "handler", "=", "self", "::", "$", "tagHandlerMappings", "[", "$", "tagName", "]", ";", "}", "}", "return", "new", "$", "handler", "(", "$", "matches", "[", "1", "]", ",", "isset", "(", "$", "matches", "[", "2", "]", ")", "?", "$", "matches", "[", "2", "]", ":", "''", ",", "$", "docblock", ",", "$", "location", ")", ";", "}" ]
Factory method responsible for instantiating the correct sub type. @param string $tag_line The text for this tag, including description. @param DocBlock $docblock The DocBlock which this tag belongs to. @param Location $location Location of the tag. @throws \InvalidArgumentException if an invalid tag line was presented. @return static A new tag object.
[ "Factory", "method", "responsible", "for", "instantiating", "the", "correct", "sub", "type", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag.php#L112-L147
34,388
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag.php
Tag.registerTagHandler
final public static function registerTagHandler($tag, $handler) { $tag = trim((string)$tag); if (null === $handler) { unset(self::$tagHandlerMappings[$tag]); return true; } if ('' !== $tag && class_exists($handler, true) && is_subclass_of($handler, __CLASS__) && !strpos($tag, '\\') //Accept no slash, and 1st slash at offset 0. ) { self::$tagHandlerMappings[$tag] = $handler; return true; } return false; }
php
final public static function registerTagHandler($tag, $handler) { $tag = trim((string)$tag); if (null === $handler) { unset(self::$tagHandlerMappings[$tag]); return true; } if ('' !== $tag && class_exists($handler, true) && is_subclass_of($handler, __CLASS__) && !strpos($tag, '\\') //Accept no slash, and 1st slash at offset 0. ) { self::$tagHandlerMappings[$tag] = $handler; return true; } return false; }
[ "final", "public", "static", "function", "registerTagHandler", "(", "$", "tag", ",", "$", "handler", ")", "{", "$", "tag", "=", "trim", "(", "(", "string", ")", "$", "tag", ")", ";", "if", "(", "null", "===", "$", "handler", ")", "{", "unset", "(", "self", "::", "$", "tagHandlerMappings", "[", "$", "tag", "]", ")", ";", "return", "true", ";", "}", "if", "(", "''", "!==", "$", "tag", "&&", "class_exists", "(", "$", "handler", ",", "true", ")", "&&", "is_subclass_of", "(", "$", "handler", ",", "__CLASS__", ")", "&&", "!", "strpos", "(", "$", "tag", ",", "'\\\\'", ")", "//Accept no slash, and 1st slash at offset 0.", ")", "{", "self", "::", "$", "tagHandlerMappings", "[", "$", "tag", "]", "=", "$", "handler", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Registers a handler for tags. Registers a handler for tags. The class specified is autoloaded if it's not available. It must inherit from this class. @param string $tag Name of tag to regiser a handler for. When registering a namespaced tag, the full name, along with a prefixing slash MUST be provided. @param string|null $handler FQCN of handler. Specifing NULL removes the handler for the specified tag, if any. @return bool TRUE on success, FALSE on failure.
[ "Registers", "a", "handler", "for", "tags", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag.php#L163-L182
34,389
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag.php
Tag.setName
public function setName($name) { if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) { throw new \InvalidArgumentException( 'Invalid tag name supplied: ' . $name ); } $this->tag = $name; return $this; }
php
public function setName($name) { if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) { throw new \InvalidArgumentException( 'Invalid tag name supplied: ' . $name ); } $this->tag = $name; return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "if", "(", "!", "preg_match", "(", "'/^'", ".", "self", "::", "REGEX_TAGNAME", ".", "'$/u'", ",", "$", "name", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid tag name supplied: '", ".", "$", "name", ")", ";", "}", "$", "this", "->", "tag", "=", "$", "name", ";", "return", "$", "this", ";", "}" ]
Sets the name of this tag. @param string $name The new name of this tag. @return $this @throws \InvalidArgumentException When an invalid tag name is provided.
[ "Sets", "the", "name", "of", "this", "tag", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag.php#L223-L234
34,390
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag.php
Tag.getContent
public function getContent() { if (null === $this->content) { $this->content = $this->description; } return $this->content; }
php
public function getContent() { if (null === $this->content) { $this->content = $this->description; } return $this->content; }
[ "public", "function", "getContent", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "content", ")", "{", "$", "this", "->", "content", "=", "$", "this", "->", "description", ";", "}", "return", "$", "this", "->", "content", ";", "}" ]
Gets the content of this tag. @return string
[ "Gets", "the", "content", "of", "this", "tag", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag.php#L241-L248
34,391
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag.php
Tag.setDescription
public function setDescription($description) { $this->content = null; $this->parsedDescription = null; $this->description = trim($description); return $this; }
php
public function setDescription($description) { $this->content = null; $this->parsedDescription = null; $this->description = trim($description); return $this; }
[ "public", "function", "setDescription", "(", "$", "description", ")", "{", "$", "this", "->", "content", "=", "null", ";", "$", "this", "->", "parsedDescription", "=", "null", ";", "$", "this", "->", "description", "=", "trim", "(", "$", "description", ")", ";", "return", "$", "this", ";", "}" ]
Sets the description component of this tag. @param string $description The new description component of this tag. @return $this
[ "Sets", "the", "description", "component", "of", "this", "tag", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag.php#L282-L289
34,392
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag.php
Tag.getParsedDescription
public function getParsedDescription() { if (null === $this->parsedDescription) { $description = new Description($this->description, $this->docblock); $this->parsedDescription = $description->getParsedContents(); } return $this->parsedDescription; }
php
public function getParsedDescription() { if (null === $this->parsedDescription) { $description = new Description($this->description, $this->docblock); $this->parsedDescription = $description->getParsedContents(); } return $this->parsedDescription; }
[ "public", "function", "getParsedDescription", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "parsedDescription", ")", "{", "$", "description", "=", "new", "Description", "(", "$", "this", "->", "description", ",", "$", "this", "->", "docblock", ")", ";", "$", "this", "->", "parsedDescription", "=", "$", "description", "->", "getParsedContents", "(", ")", ";", "}", "return", "$", "this", "->", "parsedDescription", ";", "}" ]
Gets the parsed text of this description. @return array An array of strings and tag objects, in the order they occur within the description.
[ "Gets", "the", "parsed", "text", "of", "this", "description", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag.php#L297-L304
34,393
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag/ReturnTag.php
ReturnTag.getTypesCollection
protected function getTypesCollection() { if (null === $this->types) { $this->types = new Collection( array($this->type), $this->docblock ? $this->docblock->getContext() : null ); } return $this->types; }
php
protected function getTypesCollection() { if (null === $this->types) { $this->types = new Collection( array($this->type), $this->docblock ? $this->docblock->getContext() : null ); } return $this->types; }
[ "protected", "function", "getTypesCollection", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "types", ")", "{", "$", "this", "->", "types", "=", "new", "Collection", "(", "array", "(", "$", "this", "->", "type", ")", ",", "$", "this", "->", "docblock", "?", "$", "this", "->", "docblock", "->", "getContext", "(", ")", ":", "null", ")", ";", "}", "return", "$", "this", "->", "types", ";", "}" ]
Returns the type collection. @return void
[ "Returns", "the", "type", "collection", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag/ReturnTag.php#L89-L98
34,394
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag/AuthorTag.php
AuthorTag.setAuthorName
public function setAuthorName($authorName) { $this->content = null; $this->authorName = preg_match('/^' . self::REGEX_AUTHOR_NAME . '$/u', $authorName) ? $authorName : ''; return $this; }
php
public function setAuthorName($authorName) { $this->content = null; $this->authorName = preg_match('/^' . self::REGEX_AUTHOR_NAME . '$/u', $authorName) ? $authorName : ''; return $this; }
[ "public", "function", "setAuthorName", "(", "$", "authorName", ")", "{", "$", "this", "->", "content", "=", "null", ";", "$", "this", "->", "authorName", "=", "preg_match", "(", "'/^'", ".", "self", "::", "REGEX_AUTHOR_NAME", ".", "'$/u'", ",", "$", "authorName", ")", "?", "$", "authorName", ":", "''", ";", "return", "$", "this", ";", "}" ]
Sets the author's name. @param string $authorName The new author name. An invalid value will set an empty string. @return $this
[ "Sets", "the", "author", "s", "name", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag/AuthorTag.php#L94-L102
34,395
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag/AuthorTag.php
AuthorTag.setAuthorEmail
public function setAuthorEmail($authorEmail) { $this->authorEmail = preg_match('/^' . self::REGEX_AUTHOR_EMAIL . '$/u', $authorEmail) ? $authorEmail : ''; $this->content = null; return $this; }
php
public function setAuthorEmail($authorEmail) { $this->authorEmail = preg_match('/^' . self::REGEX_AUTHOR_EMAIL . '$/u', $authorEmail) ? $authorEmail : ''; $this->content = null; return $this; }
[ "public", "function", "setAuthorEmail", "(", "$", "authorEmail", ")", "{", "$", "this", "->", "authorEmail", "=", "preg_match", "(", "'/^'", ".", "self", "::", "REGEX_AUTHOR_EMAIL", ".", "'$/u'", ",", "$", "authorEmail", ")", "?", "$", "authorEmail", ":", "''", ";", "$", "this", "->", "content", "=", "null", ";", "return", "$", "this", ";", "}" ]
Sets the author's email. @param string $authorEmail The new author email. An invalid value will set an empty string. @return $this
[ "Sets", "the", "author", "s", "email", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag/AuthorTag.php#L122-L130
34,396
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag/VersionTag.php
VersionTag.setVersion
public function setVersion($version) { $this->version = preg_match('/^' . self::REGEX_VECTOR . '$/ux', $version) ? $version : ''; $this->content = null; return $this; }
php
public function setVersion($version) { $this->version = preg_match('/^' . self::REGEX_VECTOR . '$/ux', $version) ? $version : ''; $this->content = null; return $this; }
[ "public", "function", "setVersion", "(", "$", "version", ")", "{", "$", "this", "->", "version", "=", "preg_match", "(", "'/^'", ".", "self", "::", "REGEX_VECTOR", ".", "'$/ux'", ",", "$", "version", ")", "?", "$", "version", ":", "''", ";", "$", "this", "->", "content", "=", "null", ";", "return", "$", "this", ";", "}" ]
Sets the version section of the tag. @param string $version The new version section of the tag. An invalid value will set an empty string. @return $this
[ "Sets", "the", "version", "section", "of", "the", "tag", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag/VersionTag.php#L98-L107
34,397
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag/MethodTag.php
MethodTag.getArguments
public function getArguments() { if (empty($this->arguments)) { return array(); } $arguments = explode(',', $this->arguments); foreach ($arguments as $key => $value) { $arguments[$key] = explode(' ', trim($value)); } return $arguments; }
php
public function getArguments() { if (empty($this->arguments)) { return array(); } $arguments = explode(',', $this->arguments); foreach ($arguments as $key => $value) { $arguments[$key] = explode(' ', trim($value)); } return $arguments; }
[ "public", "function", "getArguments", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "arguments", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "arguments", "=", "explode", "(", "','", ",", "$", "this", "->", "arguments", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "arguments", "[", "$", "key", "]", "=", "explode", "(", "' '", ",", "trim", "(", "$", "value", ")", ")", ";", "}", "return", "$", "arguments", ";", "}" ]
Returns an array containing each argument as array of type and name. Please note that the argument sub-array may only contain 1 element if no type was specified. @return string[]
[ "Returns", "an", "array", "containing", "each", "argument", "as", "array", "of", "type", "and", "name", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag/MethodTag.php#L170-L182
34,398
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag/ExampleTag.php
ExampleTag.setFilePath
public function setFilePath($filePath) { $this->isURI = false; $this->filePath = trim($filePath); $this->content = null; return $this; }
php
public function setFilePath($filePath) { $this->isURI = false; $this->filePath = trim($filePath); $this->content = null; return $this; }
[ "public", "function", "setFilePath", "(", "$", "filePath", ")", "{", "$", "this", "->", "isURI", "=", "false", ";", "$", "this", "->", "filePath", "=", "trim", "(", "$", "filePath", ")", ";", "$", "this", "->", "content", "=", "null", ";", "return", "$", "this", ";", "}" ]
Sets the file path. @param string $filePath The new file path to use for the example. @return $this
[ "Sets", "the", "file", "path", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag/ExampleTag.php#L121-L128
34,399
mpociot/reflection-docblock
src/Mpociot/Reflection/DocBlock/Tag/ExampleTag.php
ExampleTag.setFileURI
public function setFileURI($uri) { $this->isURI = true; if (false === strpos($uri, ':')) { //Relative URL $this->filePath = rawurldecode( str_replace(array('/', '\\'), '%2F', $uri) ); } else { //Absolute URL or URI. $this->filePath = $uri; } $this->content = null; return $this; }
php
public function setFileURI($uri) { $this->isURI = true; if (false === strpos($uri, ':')) { //Relative URL $this->filePath = rawurldecode( str_replace(array('/', '\\'), '%2F', $uri) ); } else { //Absolute URL or URI. $this->filePath = $uri; } $this->content = null; return $this; }
[ "public", "function", "setFileURI", "(", "$", "uri", ")", "{", "$", "this", "->", "isURI", "=", "true", ";", "if", "(", "false", "===", "strpos", "(", "$", "uri", ",", "':'", ")", ")", "{", "//Relative URL", "$", "this", "->", "filePath", "=", "rawurldecode", "(", "str_replace", "(", "array", "(", "'/'", ",", "'\\\\'", ")", ",", "'%2F'", ",", "$", "uri", ")", ")", ";", "}", "else", "{", "//Absolute URL or URI.", "$", "this", "->", "filePath", "=", "$", "uri", ";", "}", "$", "this", "->", "content", "=", "null", ";", "return", "$", "this", ";", "}" ]
Sets the file path as an URI. This function is equivalent to {@link setFilePath()}, except that it convers an URI to a file path before that. There is no getFileURI(), as {@link getFilePath()} is compatible. @param type $uri The new file URI to use as an example.
[ "Sets", "the", "file", "path", "as", "an", "URI", "." ]
c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587
https://github.com/mpociot/reflection-docblock/blob/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587/src/Mpociot/Reflection/DocBlock/Tag/ExampleTag.php#L140-L155