_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q235700
Collection.uniq
train
public static function uniq($collection = null, $is_sorted = null, $iterator = null) { $return = array(); if (count($collection) === 0) { return $return; } $calculated = array(); foreach ($collection as $item) { $val = (!is_null($iterator)) ? ...
php
{ "resource": "" }
q235701
Collection.first
train
public static function first($collection = null, $n = null) { if ($n === 0) { return array(); } if (is_null($n)) { return current(array_splice($collection, 0, 1, true)); } return array_splice($collection, 0, $n, true); }
php
{ "resource": "" }
q235702
Collection.rest
train
public static function rest($collection = null, $index = null) { if (is_null($index)) { $index = 1; } return array_splice($collection, $index); }
php
{ "resource": "" }
q235703
Collection.filter
train
public function filter($collection = null, $iterator = null) { $return = array(); foreach ($collection as $val) { if (call_user_func($iterator, $val)) { $return[] = $val; } } return $return; }
php
{ "resource": "" }
q235704
Misc.getRelativePath
train
public static function getRelativePath($frompath, $topath = "") { if(empty($topath)) { $topath = $frompath; $frompath = getcwd(); } if($frompath == ".") $frompath = getcwd(); if($topath == ".") $topath = getcwd(); if($frompath[0] != DIRECTORY_SEPARAT...
php
{ "resource": "" }
q235705
Misc.readPartialFile
train
public static function readPartialFile($file, $from = 0, $to = 0, $filesize = FALSE, $force = FALSE, $context = NULL) { if(!$force) { if(!@file_exists($file)) { return 404; } if(!@is_readable($file)) { return 403; } } ...
php
{ "resource": "" }
q235706
Misc.flattenArray
train
public static function flattenArray($array, $delimiter = '.', $prefix = '') { if(!is_array($array)) { return $array; } $result = array(); foreach($array as $key => $value) { if(is_array($value)) { $result = array_merge($result, self::flattenArray...
php
{ "resource": "" }
q235707
Misc.unflattenArray
train
public static function unflattenArray($array, $delimiter = '.') { if(!is_array($array)) { return $array; } $add = array(); foreach($array as $key => $value) { if(strpos($key, $delimiter) === FALSE) { continue; } $add[] = ...
php
{ "resource": "" }
q235708
Misc.redirect
train
public static function redirect($target, $status_code = 302, $loops = NULL) { if(!$loops) { $loops = Loops::getCurrentLoops(); } $config = $loops->getService("config"); $request = $loops->getService("request"); $response = $loops->getService("response"); $...
php
{ "resource": "" }
q235709
Misc.recursiveUnlink
train
public static function recursiveUnlink($dir) { $result = TRUE; if(is_dir($dir)) { foreach(scandir($dir) as $sub) { if(in_array($sub, ['.', '..'])) continue; $result &= self::recursiveUnlink("$dir/$sub"); } $result &= rmdir($dir); ...
php
{ "resource": "" }
q235710
Misc.recursiveMkdir
train
public static function recursiveMkdir($pathname, $mode = 0777, $recursive = TRUE, $context = NULL) { if(is_dir($pathname)) { return TRUE; } if($context) { return mkdir($pathname, $mode, $recursive, $context); } else { return mkdir($pathname, $...
php
{ "resource": "" }
q235711
Misc.reflectionInstance
train
public static function reflectionInstance($classname, $arguments = [], $set_remaining = FALSE, $set_include = FALSE, $set_exclude = FALSE) { $reflection = new ReflectionClass($classname); if(!$constructor = $reflection->getConstructor()) { return new $classname; } $args = se...
php
{ "resource": "" }
q235712
Misc.reflectionFunction
train
public static function reflectionFunction($function, $arguments = []) { $method = is_array($function); if($method) { $reflection = new ReflectionMethod($function[0], $function[1]); } else { $reflection = new ReflectionFunction($function); } $args...
php
{ "resource": "" }
q235713
Misc.lastChange
train
public static function lastChange($dirs, Cache $cache = NULL, &$cache_key = "") { $files = call_user_func_array("array_merge", array_map(function($dir) { if(!is_dir($dir)) return []; return iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir))); },...
php
{ "resource": "" }
q235714
Misc.fullPath
train
public static function fullPath($path, $cwd = NULL, $allow_parent = FALSE) { //unix style full paths if(substr($path, 0, 1) == DIRECTORY_SEPARATOR) { return $path; } //windows style full paths if(substr($path, 1, 2) == ":\\") { return $path; } ...
php
{ "resource": "" }
q235715
App.init
train
public function init() { self::$app = $this; spl_autoload_register(array($this['loader'], 'load')); $this->registerProviders(); $this->registerAliases(); }
php
{ "resource": "" }
q235716
App.registerProviders
train
public function registerProviders() { $providers = $this['config']->get('app.providers'); foreach ($providers as $provider) { $this->providers[$provider] = new $provider($this); $this->providers[$provider]->register(); } }
php
{ "resource": "" }
q235717
App.initDefaultClasses
train
private function initDefaultClasses() { $this['loader'] = $this->share(function ($app) { return new ClassLoader(); }); $this['config'] = $this->share(function ($app) { $config = new Config(); $config->addHint($app['path.root'] . '/resources/config/'); return $config; }); $this->instance('app', ...
php
{ "resource": "" }
q235718
ClassProfile.isDynamicAttribute
train
protected function isDynamicAttribute(AnnotationBag $propertyAnnotations) { return $propertyAnnotations->has('Query') || $propertyAnnotations->has('Statement') || $propertyAnnotations->has('Procedure') || $propertyAnnotations->has('Eval'); }
php
{ "resource": "" }
q235719
ClassProfile.parseDynamicAttribute
train
protected function parseDynamicAttribute($propertyName, \ReflectionProperty $reflectionProperty, AnnotationBag $propertyAnnotations) { if ($propertyAnnotations->has('Query')) $attribute = new Query($propertyName, $reflectionProperty, $propertyAnnotations); elseif ($propertyAnnotations->has('Statement')) $attr...
php
{ "resource": "" }
q235720
ClassProfile.isAssociation
train
protected function isAssociation(AnnotationBag $propertyAnnotations) { return $propertyAnnotations->has('OneToOne') || $propertyAnnotations->has('OneToMany') || $propertyAnnotations->has('ManyToOne') || $propertyAnnotations->has('ManyToMany'); }
php
{ "resource": "" }
q235721
ClassProfile.parseAssociation
train
protected function parseAssociation($propertyName, \ReflectionProperty $reflectionProperty, AnnotationBag $propertyAnnotations) { if ($propertyAnnotations->has('OneToOne')) { $association = new OneToOne($propertyName, $reflectionProperty, $propertyAnnotations); if ($association->isForeignKey()) { $attri...
php
{ "resource": "" }
q235722
ClassProfile.parseProperties
train
protected function parseProperties() { if ($this->isEntity()) { //property mapping $this->propertyMap = []; //associations $this->foreignkeys = $this->references = []; //read-only properties $this->readOnlyProperties = []; //duplicate checks $this->duplicateChecks = []; } $properties = ...
php
{ "resource": "" }
q235723
ClassProfile.isSafe
train
public function isSafe() { if ($this->classAnnotations->has('Safe')) return (bool) $this->classAnnotations->get('Safe')->getValue(); return false; }
php
{ "resource": "" }
q235724
aDataStore.import
train
function import($data) { if ($data === null) return $this; if (!(is_array($data) || $data instanceof \Traversable || $data instanceof \stdClass)) throw new \InvalidArgumentException(sprintf( 'Data must be instance of \Traversable, \stdClass or array. given: (...
php
{ "resource": "" }
q235725
Configuration.parseFile
train
public function parseFile(string $path): bool { static::$iteration++; if (static::$iteration > 10) exit(); if (in_array($path, $this->parsed_files)) { // The file has already been parsed, don't parse it again return true; } $this->parsed_files[] = $pat...
php
{ "resource": "" }
q235726
main.init
train
private function init() { $current_dir = realpath('.'); $output = ""; $result = array('status' => true, 'message' => ''); $server_list = $this->options->preview_server; array_push($server_list, json_decode(json_encode(array( 'name'=>'master', 'path'=>$this->options->git->repository, )))); ...
php
{ "resource": "" }
q235727
EntityManager.generateRepository
train
private function generateRepository($className) { $table = EntityReflexion::getTable($className); if ($table === NULL) { throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\""); } else { $genClassName = $this->generateRepositoryName($className); if (!class_exists($genClas...
php
{ "resource": "" }
q235728
EntityManager.generateEntity
train
private function generateEntity($className) { $genClassName = EntityManager::PREFIX . str_replace("\\", "", $className) . "Entity"; $table = EntityReflexion::getTable($className); if ($table === NULL) { throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\""); } else { if (...
php
{ "resource": "" }
q235729
Item.transform
train
public function transform() { if( ! $this->transformer) { return []; } $presentation = $this->transformer->transform($this->resource); return $this->transformToArray($presentation); }
php
{ "resource": "" }
q235730
Item.transformToArray
train
protected function transformToArray(array $presentation) { $array = []; // iterate over all the presentation values and search for arrays and // for the nested special entities, Presentation and Hidden objects // and handle each entity in the appropriate way. foreach ($prese...
php
{ "resource": "" }
q235731
PageFormBuilder.addMainFieldset
train
private function addMainFieldset(FormInterface $form) { $mainData = $form->addChild($this->getElement('nested_fieldset', [ 'name' => 'main_data', 'label' => 'common.fieldset.general', ])); $languageData = $mainData->addChild($this->getElement('language_field...
php
{ "resource": "" }
q235732
MakerMapper.mapMaker
train
public function mapMaker(?string $maker): ?string { if (null === $maker) { return null; } switch (mb_strtolower(trim($maker))) { case '': case 'unknown': case 'other': case 'bot': case 'various': $maker ...
php
{ "resource": "" }
q235733
XMLUtil.docPart
train
public static function docPart($htmlPart, $encoding = 'utf-8', $docType = NULL) { if (!is_string($htmlPart)) $htmlPart = self::export($htmlPart); if (mb_strpos(trim($htmlPart), '<!DOCTYPE') === 0) { $document = $htmlPart; } else { // DOMDocument setzt so oder so einen default, also kö...
php
{ "resource": "" }
q235734
Generic.waitFor
train
public function waitFor(callable $lambda, $attempts = 10, $waitInterval = 1) { for ($i = 0; $i < $attempts; $i++) { try { if ($lambda($this) === true) { return; } } catch (\Exception $e) { //Do nothing and pass on to...
php
{ "resource": "" }
q235735
Doctrine.setRowCount
train
public function setRowCount($rowCount) { if ($rowCount instanceof \Doctrine_Query) { $sql = $rowCount->getSql(); if (false === strpos($sql, self::ROW_COUNT_COLUMN)) { throw new \Zend_Paginator_Exception('Row count column not found'); } $resul...
php
{ "resource": "" }
q235736
GrandVision.generate
train
public function generate(...$database) { $databases = $this->getDatabaseList($database); foreach( $databases as $connection => $database ) { $this->setDatabaseConfiguration($connection, $database, $configs); $this->createVisionDirectoryByDatabaseName($database); ...
php
{ "resource": "" }
q235737
GrandVision.setDatabaseConfiguration
train
protected function setDatabaseConfiguration($connection, &$database, &$configs) { $configs = []; if( is_array($database) ) { $configs = $database; $database = $connection; } $configs['database'] = $database ?: $this->defaultDatabaseName; }
php
{ "resource": "" }
q235738
GrandVision.createVisionModelFile
train
protected function createVisionModelFile($database, $configs) { $tables = $this->getTableList($database); $database = ucfirst($database); foreach( $tables as $table ) { (new File)->object ( 'model', $this->getDatabaseVisionCl...
php
{ "resource": "" }
q235739
GrandVision.getDatabaseList
train
protected function getDatabaseList($database) { $databases = $database; if( is_array(($database[0] ?? NULL)) ) { $databases = $database[0]; } if( empty($database) ) { $databases = $this->tool->listDatabases(); } return $datab...
php
{ "resource": "" }
q235740
GrandVision.deleteVisionFile
train
protected function deleteVisionFile($database, $tables) { foreach( $tables as $table ) { unlink($this->getVisionFilePath($database, $table)); } }
php
{ "resource": "" }
q235741
GrandVision.getDatabaseVisionClassName
train
protected function getDatabaseVisionClassName($database, $table) { return INTERNAL_ACCESS . ( strtolower($database) === strtolower($this->defaultDatabaseName) ? NULL : ucfirst($database) ) . ucfirst($table) . 'Vision'; }
php
{ "resource": "" }
q235742
GrandVision.getVisionFilePath
train
protected function getVisionFilePath($database, $table) { return $this->getVisionDirectory() . Base::suffix(ucfirst($database)) . $this->getDatabaseVisionClassName($database, $table) . '.php'; }
php
{ "resource": "" }
q235743
GrandVision.stringArray
train
protected function stringArray(Array $data) { $str = EOL . HT . '[' . EOL; foreach( $data as $key => $val ) { $str .= HT . HT . "'" . $key . "' => '" . $val . "'," . EOL; } $str = Base::removeSuffix($str, ',' . EOL); $str .= EOL . HT . ']'; ret...
php
{ "resource": "" }
q235744
RpcServer.uncan
train
private function uncan($payload) { $decoded = null; if ( empty($payload) || !is_string($payload) ) throw new RpcException("Invalid Request", -32600); if ( substr($payload, 0, 27) == 'comodojo_encrypted_request-' ) { if ( empty($this->encrypt) ) throw new RpcException("Transport e...
php
{ "resource": "" }
q235745
RpcServer.can
train
private function can($response, $error) { $encoded = null; if ( $this->protocol == 'xml' ) { $encoder = new XmlrpcEncoder(); $encoder->setEncoding($this->encoding); try { $encoded = $error ? $encoder->encodeError($response->getCode(), $response->...
php
{ "resource": "" }
q235746
RpcServer.setIntrospectionMethods
train
private static function setIntrospectionMethods($methods) { $methods->add(RpcMethod::create("system.getCapabilities", '\Comodojo\RpcServer\Reserved\GetCapabilities::execute') ->setDescription("This method lists all the capabilites that the RPC server has: the (more or less standard) extensions to t...
php
{ "resource": "" }
q235747
RpcServer.setCapabilities
train
private static function setCapabilities($capabilities) { $supported_capabilities = array( 'xmlrpc' => array('http://www.xmlrpc.com/spec', 1), 'system.multicall' => array('http://www.xmlrpc.com/discuss/msgReader$1208', 1), 'introspection' => array('http://phpxmlrpc.sourceforg...
php
{ "resource": "" }
q235748
RpcServer.setErrors
train
private static function setErrors($errors) { $std_rpc_errors = array( -32700 => "Parse error", -32701 => "Parse error - Unsupported encoding", -32702 => "Parse error - Invalid character for encoding", -32600 => "Invalid Request", -32601 => "Method not...
php
{ "resource": "" }
q235749
UsersGroupsTable.findUserIdsWithOnlyOneGroup
train
public function findUserIdsWithOnlyOneGroup() { $query = $this->find(); return $query ->select([ 'user_id', 'group_count' => $query->func()->count('*') ]) ->group('user_id') ->having([ 'group_count = 1' ...
php
{ "resource": "" }
q235750
Text.contains
train
public static function contains($string = false, $substring = false) { if ($substring && $substring && strpos($string, $substring) !== false) { return true; } return false; }
php
{ "resource": "" }
q235751
Text.count
train
public static function count($string = false, $selector = false) { if ($string) { switch ($selector) { case 'words': return str_word_count($string); default: if (self::substring($selector, 0, 1) === ':') { ...
php
{ "resource": "" }
q235752
Text.lowercase
train
public static function lowercase($string = false, $selector = false) { if ($string) { switch ($selector) { case 'first': return lcfirst($string); case 'words': return lcwords($string); default: ...
php
{ "resource": "" }
q235753
Text.replace
train
public static function replace($string = false, $find = false, $replaceWith = '') { if ($string && $find) { return str_replace($find, $replaceWith, $string); } return false; }
php
{ "resource": "" }
q235754
Text.substring
train
public static function substring($string = false, $firstIndex = 0, $maxStringLength = false) { if ($string) { if (!$maxStringLength) { $maxStringLength = (self::length($string) - $firstIndex); } return substr($string, $firstIndex, $maxStringLength); ...
php
{ "resource": "" }
q235755
Text.uppercase
train
public static function uppercase($string = false, $selector = false) { if ($string) { switch ($selector) { case 'first': return ucfirst($string); case 'words': return ucwords($string); default: ...
php
{ "resource": "" }
q235756
ServerRequest.validateUploadedFiles
train
private function validateUploadedFiles(array $uploadedFiles) { foreach ($uploadedFiles as $file) { if (is_array($file)) { $this->validateUploadedFiles($file); } elseif (!$file instanceof UploadedFileInterface) { throw new InvalidArgumentException('Inva...
php
{ "resource": "" }
q235757
Locale.Create
train
public static function Create( Locale $fallbackLocale, bool $useUrlPath = true, array $acceptedRequestParams = [ 'locale', 'language', 'lang' ] ) : Locale { if ( $useUrlPath && static::TryParseUrlPath( $refLocale ) ) { return $refLocale; } if ( Locale::TryParseBrowserIn...
php
{ "resource": "" }
q235758
ThreadQueue.cleanup
train
private function cleanup() { foreach ($this->threads as $i => $szal) if (!$szal->isAlive()) { $this->results[] = $this->threads[$i]->result; unset($this->threads[$i]); } return count($this->threads); }
php
{ "resource": "" }
q235759
ThreadQueue.tick
train
public function tick() { $this->cleanup(); if ((count($this->threads) < $this->queueSize) && count($this->jobs)) { $this->threads[] = $szal = new Thread($this->callable, $this->message_length); $szal->start(array_shift($this->jobs)); } usleep(ThreadQueue::TI...
php
{ "resource": "" }
q235760
MultiParam._transform
train
protected function _transform() { $index = 1; foreach ($this->_values as $value) { $paramName = "{$this->_name}_{$index}"; $this->_params[$paramName] = new Param($this->_type, $value); $index++; } }
php
{ "resource": "" }
q235761
Language.getCurrentUiLang
train
public function getCurrentUiLang($isTwoLetter = false) { $uiLcid3 = Configure::read('Config.language'); if (empty($uiLcid3)) { $uiLcid3 = 'eng'; } $uiLcid3 = mb_strtolower($uiLcid3); if (!$isTwoLetter) { return $uiLcid3; } return $this->convertLangCode($uiLcid3, 'iso639-1'); }
php
{ "resource": "" }
q235762
Language.convertLangCode
train
public function convertLangCode($langCode = null, $output = null) { $result = ''; if (empty($langCode) || empty($output)) { return $result; } $cachePath = 'lang_code_info_' . md5(serialize(func_get_args())); $cached = Cache::read($cachePath, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE); if (!empty($cached)) { ...
php
{ "resource": "" }
q235763
Language.getLangForNumberText
train
public function getLangForNumberText($langCode = null) { $cachePath = 'lang_code_number_name_' . md5(serialize(func_get_args())); $cached = Cache::read($cachePath, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE); if (!empty($cached)) { return $cached; } if (!empty($langCode)) { $langUI = $this->convertLangCode($l...
php
{ "resource": "" }
q235764
AbstractTextWriter.toScalarTable
train
public static function toScalarTable($list) { return iter\iterable($list) ->map( function ($record) { return self::toScalarValues($record); } ); }
php
{ "resource": "" }
q235765
WebDriver.forward
train
public function forward() { $this->getDriver()->curl($this->getDriver()->factoryCommand('forward', WebDriver_Command::METHOD_POST)); return $this; }
php
{ "resource": "" }
q235766
WebDriver.back
train
public function back() { $this->getDriver()->curl($this->getDriver()->factoryCommand('back', WebDriver_Command::METHOD_POST)); return $this; }
php
{ "resource": "" }
q235767
WebDriver.refresh
train
public function refresh() { $this->getDriver()->curl($this->getDriver()->factoryCommand('refresh', WebDriver_Command::METHOD_POST)); return $this; }
php
{ "resource": "" }
q235768
WebDriver.execute
train
public function execute($js, $args = []) { $params = ['script' => $js, 'args' => $args]; $result = $this->getDriver()->curl( $this->getDriver()->factoryCommand('execute', WebDriver_Command::METHOD_POST, $params) ); return isset($result['value'])?$result['value']:false; ...
php
{ "resource": "" }
q235769
WebDriver.screenshotAsImage
train
public function screenshotAsImage($asBase64 = false) { $image = $this->getDriver()->curl( $this->getDriver()->factoryCommand('screenshot', WebDriver_Command::METHOD_GET) ); $image = $image['value']; if (!$asBase64) { $image = base64_decode($image); } ...
php
{ "resource": "" }
q235770
WebDriver.findAll
train
public function findAll($locator, $parent = null) { $commandUri = empty($parent) ? "elements" : "element/{$parent->getElementId()}/elements"; $command = $this->getDriver()->factoryCommand( $commandUri, WebDriver_Command::METHOD_POST, WebDriver_Util::parseLocator($...
php
{ "resource": "" }
q235771
WebDriver.keys
train
public function keys($charList) { $this->getDriver()->curl( $this->getDriver()->factoryCommand( 'keys', WebDriver_Command::METHOD_POST, ['value' => WebDriver_Util::prepareKeyStrokes($charList)] ) ); return $this; }
php
{ "resource": "" }
q235772
WebDriver.source
train
public function source() { $command = $this->getDriver()->factoryCommand('source', WebDriver_Command::METHOD_GET); $result = $this->getDriver()->curl($command); return $result['value']; }
php
{ "resource": "" }
q235773
WebDriver.cache
train
public function cache() { if (null === $this->cache) { $this->cache = new WebDriver_Cache($this); } return $this->cache; }
php
{ "resource": "" }
q235774
NestedArray.mergeDeepArray
train
public static function mergeDeepArray(array $arrays, $preserve_integer_keys = false) { $result = []; foreach ($arrays as $array) { foreach ($array as $key => $value) { if (is_integer($key) && !$preserve_integer_keys) { // Renumber integer keys as arra...
php
{ "resource": "" }
q235775
DynamicAttribute.parseArguments
train
protected function parseArguments(AnnotationBag $propertyAnnotations) { $this->args = []; //parse additional arguments $parameters = $propertyAnnotations->find('Param'); foreach ($parameters as $param) { if ($param->hasArgument()) { $arg = $param->getArgument(); if (strtolower($arg) == 'se...
php
{ "resource": "" }
q235776
DynamicAttribute.parseConfig
train
protected function parseConfig(AnnotationBag $propertyAnnotations) { $this->config = []; //mapping type expression if (isset($this->type)) $this->config['map.type'] = $this->type; //result map if ($propertyAnnotations->has('ResultMap')) $this->config['map.result'] = $propertyAnnotations->get('Resu...
php
{ "resource": "" }
q235777
DynamicAttribute.evaluateCondition
train
protected function evaluateCondition($row, $config) { if (isset($this->condition)) return call_user_func($this->condition, $row, $config); return true; }
php
{ "resource": "" }
q235778
Implementation.getSubscription
train
public function getSubscription() { if ($this->getGateway() instanceof GatewayInterface) { return $this->getGateway()->getSubscriptionByReference($this->getSubscriptionReference()); } throw new RuntimeException('Gateway is not set'); }
php
{ "resource": "" }
q235779
Hasher.file
train
public function file(SplFileInfo $file) { return substr($this->base(hash_file('sha256', $file->getRealPath(), true)), 0, 32); }
php
{ "resource": "" }
q235780
Parser.parse
train
private function parse() { // Skip if already parsed! if ($this->parsed) { return; } // Type switch switch($this->query->mode){ case Query::MODE_SELECT: $this->parseSelectQuery(); break; case Query::MODE_INSERT: ...
php
{ "resource": "" }
q235781
Parser.parseSelectQuery
train
private function parseSelectQuery() { // Parse select ? $selectSql = Column::generateQueryString($this->query->select); // Parse table $fromSql = Table::generateQueryString($this->query->table); $whereSql = null; $whereBind = array(); $sql = [ ...
php
{ "resource": "" }
q235782
Parser.combineSelectQuery
train
private function combineSelectQuery($sqlParts) { // Add select columns and tables. $output = "SELECT " . $sqlParts['select'] . " FROM " . $sqlParts['from']; // Add where when defined. if ($sqlParts['where'] !== null) { // Add where $output .= " WHERE " . $sql...
php
{ "resource": "" }
q235783
PropelIndexComparator.computeDiff
train
static public function computeDiff(Index $fromIndex, Index $toIndex, $caseInsensitive = false) { // Check for removed index columns in $toIndex $fromIndexColumns = $fromIndex->getColumns(); for($i = 0; $i < count($fromIndexColumns); $i++) { $indexColumn = $fromIndexColumns[$i]; if (!$toIndex->hasColumnAtPo...
php
{ "resource": "" }
q235784
redis_phpCacheDriver.get
train
public function get($key) { $used_key = $this->getUsedKey($key); $res = $this->redis->get($used_key); if ($res === null) return false; $res = $this->unesc($res); if (is_array($key)) { return array_combine($key, $res); } else { r...
php
{ "resource": "" }
q235785
redis_phpCacheDriver.set
train
public function set($key, $value, $ttl = 0) { if (is_resource($value)) { return false; } $used_key = $this->getUsedKey($key); $res = $this->redis->set($used_key, $this->esc($value)); if ($res !== 'OK') { return false; } if ($ttl === 0) { ...
php
{ "resource": "" }
q235786
redis_phpCacheDriver.delete
train
public function delete($key) { $used_key = $this->getUsedKey($key); return ($this->redis->delete($used_key) > 0); }
php
{ "resource": "" }
q235787
redis_phpCacheDriver.flush
train
public function flush() { if (!$this->key_prefix) { return ($this->redis->flushdb() == 'OK'); } switch($this->key_prefix_flush_method) { case 'direct': $this->redis->flushByPrefix($this->key_prefix); return true; case 'event': ...
php
{ "resource": "" }
q235788
JiraService.setWorklog
train
public function setWorklog($date, $ticket, $timeSpent, $comment = '') { $this->uri = "{$this->site}/rest/api/2/issue/{$ticket}/worklog"; if (is_numeric($timeSpent)) { $timeSpent .= 'h'; } $startedDate = $this->_formatTimestamp($date); $data = [ 'time...
php
{ "resource": "" }
q235789
ComposerTaskFactory.createUpgrade
train
protected function createUpgrade($metaData) { $this->ensureHomePath($metaData); if (!$metaData->has(UpgradeTask::SETTING_DATA_DIR)) { $metaData->set(UpgradeTask::SETTING_DATA_DIR, $this->home->tensideDataDir()); } return new UpgradeTask($metaData); }
php
{ "resource": "" }
q235790
ComposerTaskFactory.ensureHomePath
train
private function ensureHomePath(JsonArray $metaData) { if ($metaData->has(AbstractPackageManipulatingTask::SETTING_HOME)) { return; } $metaData->set(AbstractPackageManipulatingTask::SETTING_HOME, $this->home->homeDir()); }
php
{ "resource": "" }
q235791
EventTrait.on
train
public function on($type, $callback) { if (!isset($this->callbacks[$type])) { $this->callbacks[$type] = []; } $this->callbacks[$type][] = $callback; return $this; }
php
{ "resource": "" }
q235792
NewsArchieve.preSaveText
train
public static function preSaveText($text, $controller, $transTable = []) { $module = Module::getModuleByClassname(Module::className()); $editorContentHelper = $module->contentHelper; $text = trim($text); if (empty($text)) return ''; $text = $editorContentHelper...
php
{ "resource": "" }
q235793
NewsArchieve.getSlug
train
public static function getSlug($model) { $i18nModels = $model->i18n; $slugs = []; foreach ($i18nModels as $i18nModel) { if (empty($i18nModel->body)) continue; // skip languages for news without body $slugs[$i18nModel->lang_code] = $i18nModel->slug; } ...
php
{ "resource": "" }
q235794
Range.contains
train
public function contains($key) { if ($this->inclusive && in_array($key, array($this->min, $this->max))) { return true; } return $key > $this->min && $key < $this->max; }
php
{ "resource": "" }
q235795
JsonApiResponse.setLinks
train
public function setLinks() { // Only required for collections as items contain links by default if ($this->resource instanceof Collection && $paginator = $this->resource->getPaginator()) { $pagination = new Pagination($paginator); $this->links = $pagination->generateCollectio...
php
{ "resource": "" }
q235796
JsonApiResponse.setData
train
public function setData() { // Process a collection if ($this->resource instanceof Collection) { $this->data = []; foreach ($this->resource->getData() as $resource) { $this->parseItem(new Item($resource, $this->resource->getTransformer())); } ...
php
{ "resource": "" }
q235797
JsonApiResponse.parseItem
train
private function parseItem(Item $item) { // Get and format an item $tmp = $this->getFormattedItem($item); // Get related data $relationships = $this->getRelationships($item); // Closure function to internally parse related includes $parseRelationships = function($ke...
php
{ "resource": "" }
q235798
JsonApiResponse.getFormattedItem
train
private function getFormattedItem(Item $item) { $data = [ 'type' => $this->getFormattedName($item->getTransformer()), 'id' => $item->getData()->id, 'attributes' => $item->sanitize(), ]; if ($links = $item->getLinks()) { $data['li...
php
{ "resource": "" }
q235799
JsonApiResponse.getFormattedName
train
private function getFormattedName($class) { $class_name = (substr(strrchr(get_class($class), "\\"), 1)); $underscored = preg_replace('/([a-z])([A-Z])/', '$1_$2', $class_name); return strtolower($underscored); }
php
{ "resource": "" }