_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q260400 | ListTask.describeRoute | test | protected function describeRoute(Route $route)
{
$paths = $route->getPaths();
$class = $paths['task'];
$action = Arr::fetch($paths, 'action', 'main') . $this->dispatcher->getActionSuffix();
$this->scanned[$class . '::' . $action] = true;
$compiled = Helper::describeRoutePattern($route, true);
$this->describe($compiled, $class, $action);
} | php | {
"resource": ""
} |
q260401 | ClassLoader.addDirectories | test | public function addDirectories($directories)
{
$this->directories = array_merge($this->directories, (array)$directories);
$this->directories = array_unique($this->directories);
} | php | {
"resource": ""
} |
q260402 | ClassLoader.normalizeClass | test | protected function normalizeClass($class)
{
// Strip first slash
$class = ltrim($class, '\\');
// Work backwards through the namespace names of the fully-qualified
// class name to find a mapped file name
$pos = strrpos($class, '\\');
// Retain the trailing namespace separator in the prefix
$directory = substr($class, 0, $pos + 1);
// The rest is the relative class name
$relativeClass = substr($class, $pos + 1);
$directory = str_replace(['\\', '.'], DIRECTORY_SEPARATOR, $directory);
$directory = trim($directory, DIRECTORY_SEPARATOR);
$lowerClass = strtolower($directory).DIRECTORY_SEPARATOR.$relativeClass;
$upperClass = $directory.DIRECTORY_SEPARATOR.$relativeClass;
return [$lowerClass, $upperClass];
} | php | {
"resource": ""
} |
q260403 | ClassLoader.loadMappedClass | test | protected function loadMappedClass($class)
{
list($lowerClass, $upperClass) = $this->normalizeClass($class);
// Look through registered directories
foreach ($this->directories as $directory) {
// If the mapped class exists, require it
if ($this->isRealFilePath($path = $directory.DIRECTORY_SEPARATOR.$lowerClass.'.php')) {
$this->requireClass($class, $path);
return $path;
}
if ($this->isRealFilePath($path = $directory.DIRECTORY_SEPARATOR.$upperClass.'.php')) {
$this->requireClass($class, $path);
return TRUE;
}
}
// never found it
return FALSE;
} | php | {
"resource": ""
} |
q260404 | ClassLoader.requireClass | test | protected function requireClass($class, $path)
{
require_once $this->basePath.DIRECTORY_SEPARATOR.$path;
$this->manifest[$class] = $path;
$this->manifestIsDirty = TRUE;
} | php | {
"resource": ""
} |
q260405 | ClassLoader.loadManifest | test | protected function loadManifest()
{
if (!is_null($this->manifest)) {
return;
}
if (file_exists($this->manifestPath)) {
try {
$this->manifest = $this->files->getRequire($this->manifestPath);
if (!is_array($this->manifest)) {
$this->manifest = [];
}
} catch (Exception $ex) {
$this->manifest = [];
}
}
else {
$this->manifest = [];
}
} | php | {
"resource": ""
} |
q260406 | ClassLoader.write | test | protected function write(array $manifest)
{
if (!is_writable($path = dirname($this->manifestPath))) {
throw new Exception('The '.$path.' directory must be present and writable.');
}
$this->files->put(
$this->manifestPath, '<?php return '.var_export($manifest, TRUE).';'
);
} | php | {
"resource": ""
} |
q260407 | FileLoader.loadFromDrivers | test | public function loadFromDrivers($locale, $group, $namespace = null)
{
return collect($this->drivers)->map(function ($className) {
return app($className);
})->mapWithKeys(function (Contracts\Driver $driver) use ($locale, $group, $namespace) {
return $driver->load($locale, $group, $namespace);
})->toArray();
} | php | {
"resource": ""
} |
q260408 | FileLoader.loadPath | test | protected function loadPath($path, $locale, $group)
{
return collect(['_lang.php', '.php'])
->reduce(function ($output, $ext) use ($path, $locale, $group) {
if ($this->files->exists($full = "{$path}/{$locale}/{$group}{$ext}")) {
$output = array_merge($output, $this->files->getRequire($full));
}
return $output;
}, []);
} | php | {
"resource": ""
} |
q260409 | DatabaseSettingStore.setConstraint | test | public function setConstraint(\Closure $callback)
{
$this->items = [];
$this->loaded = FALSE;
$this->queryConstraint = $callback;
} | php | {
"resource": ""
} |
q260410 | DatabaseSettingStore.parseReadData | test | protected function parseReadData($data)
{
$results = [];
foreach ($data as $row) {
if (is_array($row)) {
$key = $row[$this->keyColumn];
$value = $this->parseKeyValue($row[$this->valueColumn]);
}
elseif (is_object($row)) {
$key = $row->{$this->keyColumn};
$value = $this->parseKeyValue($row->{$this->valueColumn});
}
else {
throw new UnexpectedValueException('Expected array or object, got '.gettype($row));
}
Arr::set($results, $key, $value);
}
return $results;
} | php | {
"resource": ""
} |
q260411 | DatabaseSettingStore.newQuery | test | protected function newQuery($insert = FALSE)
{
$query = $this->db->table($this->table);
if (!$insert) {
foreach ($this->extraColumns as $key => $value) {
$query->where($key, '=', $value);
}
}
if ($this->queryConstraint !== null) {
$callback = $this->queryConstraint;
$callback($query, $insert);
}
return $query;
} | php | {
"resource": ""
} |
q260412 | Decorate.hasColorSupport | test | private static function hasColorSupport()
{
if (isset(self::$hasColorSupport)) {
return self::$hasColorSupport;
}
if (DIRECTORY_SEPARATOR === '\\') {
return self::$hasColorSupport =
(10 == PHP_WINDOWS_VERSION_MAJOR && PHP_WINDOWS_VERSION_BUILD >= 10586)
|| false !== getenv('ANSICON')
|| 'ON' === getenv('ConEmuANSI')
|| 'xterm' === getenv('TERM');
}
return self::$hasColorSupport = function_exists('posix_isatty') && @posix_isatty(STDOUT);
} | php | {
"resource": ""
} |
q260413 | Decorate.apply | test | public static function apply($text, $foreground = null, $background = null, array $options = [])
{
if (!self::hasColorSupport()) {
return $text;
}
$setCodes = [];
$unsetCodes = [];
if (null !== $foreground) {
$setCodes[] = self::$availableForegroundColors[$foreground]['set'];
$unsetCodes[] = self::$availableForegroundColors[$foreground]['unset'];
}
if (null !== $background) {
$setCodes[] = self::$availableBackgroundColors[$background]['set'];
$unsetCodes[] = self::$availableBackgroundColors[$background]['unset'];
}
if (!empty($options)) {
foreach ($options as $option) {
$setCodes[] = self::$availableOptions[$option]['set'];
$unsetCodes[] = self::$availableOptions[$option]['unset'];
}
}
if (0 === count($setCodes)) {
return $text;
}
return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
} | php | {
"resource": ""
} |
q260414 | FileStorage.getRan | test | public function getRan()
{
$data = $this->getData();
array_multisort(
array_column($data, 'batch'), SORT_ASC,
array_column($data, 'migration'), SORT_ASC,
$data
);
return Arr::pluck($data, 'migration');
} | php | {
"resource": ""
} |
q260415 | FileStorage.getMigrations | test | public function getMigrations($steps)
{
$data = $this->getData();
$data = array_filter($data, function ($datum) {
return (int)$datum['batch'] >= 1;
});
array_multisort(
array_column($data, 'batch'), SORT_DESC,
array_column($data, 'migration'), SORT_DESC,
$data
);
return array_slice($data, 0, $steps);
} | php | {
"resource": ""
} |
q260416 | Migrator.run | test | public function run($paths = [], array $options = [])
{
$this->notes = [];
// Once we grab all of the migration files for the path, we will compare them
// against the migrations that have already been run for this package then
// run each of the outstanding migrations against a database connection.
$files = $this->getMigrationFiles($paths);
$this->requireFiles($migrations = $this->pendingMigrations(
$files, $this->storage->getRan()
));
// Once we have all these migrations that are outstanding we are ready to run
// we will go ahead and run them "up". This will execute each migration as
// an operation against a database. Then we'll return this list of them.
$this->runPending($migrations, $options);
return $migrations;
} | php | {
"resource": ""
} |
q260417 | Migrator.runUp | test | protected function runUp($file, $batch, $pretend = false)
{
// First we will resolve a "real" instance of the migration class from this
// migration file name. Once we have the instances we can run the actual
// command such as "up" or "down", or we can just simulate the action.
$migration = $this->resolve(
$name = $this->getMigrationName($file)
);
if ($pretend) {
$this->pretendToRun($name, $migration, 'up');
return;
}
$this->note(Decorate::notice('Migrating:') . " {$name}");
$this->runMigration($migration, 'up');
// Once we have run a migrations class, we will log that it was run in this
// repository so that we don't try to run it next time we do a migration
// in the application. A migration repository keeps the migrate order.
$this->storage->log($name, $batch);
$this->note(Decorate::info('Migrated:') . " {$name}");
} | php | {
"resource": ""
} |
q260418 | Migrator.getMigrationsForRollback | test | protected function getMigrationsForRollback(array $options)
{
$steps = Arr::get($options, 'step', 0);
if ($steps > 0) {
return $this->storage->getMigrations($steps);
} else {
return $this->storage->getLast();
}
} | php | {
"resource": ""
} |
q260419 | Migrator.rollbackMigrations | test | protected function rollbackMigrations(array $migrations, $paths, array $options)
{
$rolledBack = [];
$pretend = Arr::get($options, 'pretend', false);
$this->requireFiles($files = $this->getMigrationFiles($paths));
// Next we will run through all of the migrations and call the "down" method
// which will reverse each migration in order. This getLast method on the
// repository already returns these migration's names in reverse order.
foreach ($migrations as $migration) {
$migration = (object)$migration;
if (!$file = Arr::get($files, $migration->migration)) {
continue;
}
$rolledBack[] = $file;
$this->runDown($file, $migration, $pretend);
}
return $rolledBack;
} | php | {
"resource": ""
} |
q260420 | Migrator.reset | test | public function reset($paths = [], array $options = [])
{
$this->notes = [];
// Next, we will reverse the migration list so we can run them back in the
// correct order for resetting this database. This will allow us to get
// the database back into its "empty" state ready for the migrations.
$migrations = array_reverse($this->storage->getRan());
if (count($migrations) === 0) {
$this->note(Decorate::info('Nothing to rollback.'));
return [];
} else {
return $this->resetMigrations($migrations, $paths, $options);
}
} | php | {
"resource": ""
} |
q260421 | Migrator.resetMigrations | test | protected function resetMigrations(array $migrations, array $paths, array $options)
{
// Since the getRan method that retrieves the migration name just gives us the
// migration name, we will format the names into objects with the name as a
// property on the objects so that we can pass it to the rollback method.
$migrations = array_map(function ($m) {
return (object)['migration' => $m];
}, $migrations);
return $this->rollbackMigrations($migrations, $paths, $options);
} | php | {
"resource": ""
} |
q260422 | Migrator.runDown | test | protected function runDown($file, $migration, $pretend = false)
{
// First we will get the file name of the migration so we can resolve out an
// instance of the migration. Once we get an instance we can either run a
// pretend execution of the migration or we can run the real migration.
$instance = $this->resolve(
$name = $this->getMigrationName($file)
);
if ($pretend) {
$this->pretendToRun($name, $instance, 'down');
return;
}
$this->note(Decorate::notice('Rolling back:') . " {$name}");
$this->runMigration($instance, 'down');
// Once we have successfully run the migration "down" we will remove it from
// the migration repository so it will be considered to have not been run
// by the application then will be able to fire by any later operation.
$this->storage->delete($migration->migration);
$this->note(Decorate::info('Rolled back:') . " {$name}");
} | php | {
"resource": ""
} |
q260423 | Migrator.pretendToRun | test | protected function pretendToRun($name, $instance, $method)
{
$this->note(Decorate::info($name) . ': ');
$queries = Db::pretend(function () use ($instance, $method) {
$this->runMigration($instance, $method);
});
$sql = Highlighter::factory(SQL::class, Shell::class);
foreach ($queries as $query) {
$this->note($sql->highlight($query));
}
$this->note('');
} | php | {
"resource": ""
} |
q260424 | Migrator.getMigrationFiles | test | public function getMigrationFiles($paths)
{
$paths = array_map(function ($path) {
return glob($path . '/*_*.php');
}, (array)$paths);
$paths = array_filter(Arr::collapse($paths));
$migrations = [];
foreach ($paths as $path) {
$migrations[$this->getMigrationName($path)] = $path;
}
ksort($migrations, SORT_REGULAR);
return $migrations;
} | php | {
"resource": ""
} |
q260425 | ClearCompiledTask.clearLoader | test | private static function clearLoader($compileDir)
{
if (file_exists($compileDir . 'loader.php')) {
@unlink($compileDir . 'loader.php');
}
if (file_exists($compileDir . 'compile.php')) {
@unlink($compileDir . 'compile.php');
}
} | php | {
"resource": ""
} |
q260426 | Model.primary | test | protected function primary($name, $type, array $options = [])
{
static::addColumn($name, $type, isset($options['map']) ? $options['map'] : $name);
static::$metaDatasClass[static::class][MetaData::MODELS_PRIMARY_KEY][] = $name;
static::$metaDatasClass[static::class][MetaData::MODELS_NOT_NULL][] = $name;
if (
(!isset($options['identity']) || $options['identity']) &&
(!isset($options['multiple']) || !$options['multiple'])
) {
static::$metaDatasClass[static::class][MetaData::MODELS_IDENTITY_COLUMN] = $name;
}
if (
(!isset($options['autoIncrement']) || $options['autoIncrement']) &&
(!isset($options['multiple']) || !$options['multiple'])
) {
static::$metaDatasClass[static::class][MetaData::MODELS_AUTOMATIC_DEFAULT_INSERT][$name] = true;
}
} | php | {
"resource": ""
} |
q260427 | Model.column | test | protected function column($name, $type, array $options = [])
{
static::addColumn($name, $type, isset($options['map']) ? $options['map'] : $name);
static::$metaDatasClass[static::class][MetaData::MODELS_NON_PRIMARY_KEY][] = $name;
if (isset($options['nullable']) && $options['nullable']) {
static::$metaDatasClass[static::class][MetaData::MODELS_EMPTY_STRING_VALUES][$name] = true;
} else {
static::$metaDatasClass[static::class][MetaData::MODELS_NOT_NULL][] = $name;
}
if (isset($options['default'])) {
static::$metaDatasClass[static::class][MetaData::MODELS_DEFAULT_VALUES][$name] = $options['default'];
}
if (isset($options['autoInsert']) && $options['autoInsert']) {
static::$metaDatasClass[static::class][MetaData::MODELS_AUTOMATIC_DEFAULT_INSERT][$name] = true;
}
if (isset($options['autoUpdate']) && $options['autoUpdate']) {
static::$metaDatasClass[static::class][MetaData::MODELS_AUTOMATIC_DEFAULT_UPDATE][$name] = true;
}
} | php | {
"resource": ""
} |
q260428 | Model.timestampable | test | protected function timestampable($name, array $options = [])
{
if ((isset($options['autoInsert']) && $options['autoInsert']) ||
(isset($options['autoUpdate']) && $options['autoUpdate'])
) {
throw new \RuntimeException('Model: A timestampable field can\'t have autoInsert or autoUpdate.');
}
self::column($name, isset($options['type']) ? $options['type'] : Column::TYPE_DATETIME, $options);
$params = [];
if (!isset($options['default']) && isset($options['insert']) && $options['insert']) {
$params['beforeValidationOnCreate'] = [
'field' => $name,
'format' => isset($options['format']) ? $options['format'] : DATE_ATOM
];
}
if (isset($options['update']) && $options['update']) {
$params['beforeValidationOnUpdate'] = [
'field' => $name,
'format' => isset($options['format']) ? $options['format'] : DATE_ATOM
];
}
if(empty($params)){
throw new \RuntimeException('Model: A timestampable field needs to have at least insert or update.');
}
$this->addBehavior(new Timestampable($params));
} | php | {
"resource": ""
} |
q260429 | Model.softDeletable | test | protected function softDeletable($name, array $options = [])
{
if ((isset($options['autoInsert']) && $options['autoInsert']) ||
(isset($options['autoUpdate']) && $options['autoUpdate'])
) {
throw new \RuntimeException('Model: A timestampable field can\'t have autoInsert or autoUpdate.');
}
self::column($name, isset($options['type']) ? $options['type'] : Column::TYPE_BOOLEAN, $options);
$this->addBehavior(new SoftDelete([
'field' => $name,
'value' => isset($options['value']) ? $options['value'] : true
]));
} | php | {
"resource": ""
} |
q260430 | Model.addColumn | test | private static function addColumn($name, $type, $map)
{
static::$columnsMapClass[static::class][$name] = $map;
static::$metaDatasClass[static::class][MetaData::MODELS_ATTRIBUTES][] = $name;
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES][$name] = $type;
static::describeColumnType($name, $type);
} | php | {
"resource": ""
} |
q260431 | Model.describeColumnType | test | private static function describeColumnType($name, $type)
{
if ($type === null) {
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_BIND][$name] = Column::BIND_PARAM_NULL;
} elseif (
$type === Column::TYPE_BIGINTEGER ||
$type === Column::TYPE_INTEGER ||
$type === Column::TYPE_TIMESTAMP
) {
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_BIND][$name] = Column::BIND_PARAM_INT;
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_NUMERIC][$name] = true;
} elseif (
$type === Column::TYPE_DECIMAL ||
$type === Column::TYPE_FLOAT ||
$type === Column::TYPE_DOUBLE
) {
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_BIND][$name] = Column::BIND_PARAM_DECIMAL;
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_NUMERIC][$name] = true;
} elseif (
$type === Column::TYPE_JSON ||
$type === Column::TYPE_TEXT ||
$type === Column::TYPE_CHAR ||
$type === Column::TYPE_VARCHAR ||
$type === Column::TYPE_DATE ||
$type === Column::TYPE_DATETIME
) {
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_BIND][$name] = Column::BIND_PARAM_STR;
} elseif (
$type === Column::TYPE_BLOB ||
$type === Column::TYPE_JSONB ||
$type === Column::TYPE_MEDIUMBLOB ||
$type === Column::TYPE_TINYBLOB ||
$type === Column::TYPE_LONGBLOB
) {
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_BIND][$name] = Column::BIND_PARAM_BLOB;
} elseif ($type === Column::TYPE_BOOLEAN) {
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_BIND][$name] = Column::BIND_PARAM_BOOL;
} else {
static::$metaDatasClass[static::class][MetaData::MODELS_DATA_TYPES_BIND][$name] = Column::BIND_SKIP;
}
} | php | {
"resource": ""
} |
q260432 | Task.hasOption | test | protected function hasOption(...$options)
{
foreach ($options as $option) {
if (Arr::has($this->options, $option)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q260433 | Category.isParentIdSame | test | protected function isParentIdSame()
{
$dirty = $this->getDirty();
$oldNavItem = self::where('id','=',$this->id)->first();
$oldParent = $oldNavItem->parent;
$oldParentId = $oldParent->id;
$isParentColumnSet = isset($dirty[$this->getParentColumnName()]);
if ($isParentColumnSet)
{
$isNewParentSameAsOld = $dirty[$this->getParentColumnName()] == $oldParentId;
}
else
{
$isNewParentSameAsOld = false;
}
return $isParentColumnSet && $isNewParentSameAsOld;
} | php | {
"resource": ""
} |
q260434 | Category.scopeLive | test | public function scopeLive($query)
{
return $query->where('status', '=', self::APPROVED)
->where('published_date', '<=', \Carbon\Carbon::now());
} | php | {
"resource": ""
} |
q260435 | Category.getPathAttribute | test | public function getPathAttribute()
{
$ancestors = $this->getAncestors();
$return = array();
foreach($ancestors as $ancestor) {
$return[] = $ancestor->name;
}
$return[] = $this->name;
return implode(' > ', $return);
} | php | {
"resource": ""
} |
q260436 | Crypt.register | test | protected function register()
{
$app = $this->config->app;
$crypt = new \Phalcon\Crypt($app->cipher);
$crypt->setKey($app->key);
return $crypt;
} | php | {
"resource": ""
} |
q260437 | ConfigCacheTask.mainAction | test | public function mainAction()
{
$this->output->write(Decorate::notice(str_pad('Generating configuration cache', 40, ' ')), false);
$preloader = new ConfigPreloader();
try {
$preloader->compile();
$this->info("Success");
} catch (\Exception $e) {
$this->error("Error");
$this->block([$e->getMessage()], 'error');
}
} | php | {
"resource": ""
} |
q260438 | MysqlTrait.renameTable | test | public function renameTable($from, $to, $schema = null)
{
return "RENAME TABLE " . $this->prepareTable($from, $schema) . " TO " . $this->prepareTable($to, $schema);
} | php | {
"resource": ""
} |
q260439 | HasPermalink.bootHasPermalink | test | public static function bootHasPermalink()
{
if (!property_exists(get_called_class(), 'permalinkable')) {
throw new Exception(sprintf(
'You must define a $permalinkable property in %s to use the HasPermalink trait.', get_called_class()
));
}
static::saving(function (Model $model) {
$model->generatePermalinkOnSave();
});
} | php | {
"resource": ""
} |
q260440 | HasPermalink.getSlugKeyName | test | public function getSlugKeyName()
{
if (property_exists($this, 'slugKeyName')) {
return $this->slugKeyName;
}
$config = $this->permalinkable();
$name = reset($config);
$key = key($config);
// check for short configuration
if ($key === 0) {
return $name;
}
return $key;
} | php | {
"resource": ""
} |
q260441 | HasPermalink.scopeFindSimilarSlugs | test | public function scopeFindSimilarSlugs($query, $attribute, array $config, $slug)
{
$separator = $config['separator'];
return $query->where($attribute, $slug)
->orWhere($attribute, 'LIKE', $slug.$separator.'%');
} | php | {
"resource": ""
} |
q260442 | DatabaseStrategy.query | test | public function query($sqlStatement, $placeholders = null, $dataTypes = null, ...$args)
{
return $this->uses()->query($sqlStatement, $placeholders, $dataTypes, ...$args);
} | php | {
"resource": ""
} |
q260443 | DatabaseStrategy.execute | test | public function execute($sqlStatement, $placeholders = null, $dataTypes = null, ...$args)
{
return $this->uses()->execute($sqlStatement, $placeholders, $dataTypes, ...$args);
} | php | {
"resource": ""
} |
q260444 | DatabaseStrategy.describeColumns | test | public function describeColumns($table, $schema = null, ...$args)
{
return $this->uses()->describeColumns($table, $schema, ...$args);
} | php | {
"resource": ""
} |
q260445 | DatabaseStrategy.fetchOne | test | public function fetchOne($sqlQuery, $fetchMode = 2, $placeholders = null, ...$args)
{
return $this->uses()->fetchOne($sqlQuery, $fetchMode, $placeholders, ...$args);
} | php | {
"resource": ""
} |
q260446 | DatabaseStrategy.fetchAll | test | public function fetchAll($sqlQuery, $fetchMode = 2, $placeholders = null, ...$args)
{
return $this->uses()->fetchAll($sqlQuery, $fetchMode, $placeholders, ...$args);
} | php | {
"resource": ""
} |
q260447 | DatabaseStrategy.insert | test | public function insert($table, array $values, $fields = null, $dataTypes = null, ...$args)
{
return $this->uses()->insert($table, $values, $fields, $dataTypes, ...$args); } | php | {
"resource": ""
} |
q260448 | DatabaseStrategy.update | test | public function update($table, $fields, $values, $whereCondition = null, $dataTypes = null, ...$args)
{
return $this->uses()->update($table, $fields, $values, $whereCondition, $dataTypes, ...$args);
} | php | {
"resource": ""
} |
q260449 | DatabaseStrategy.delete | test | public function delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null, ...$args)
{
return $this->uses()->delete($table, $whereCondition, $placeholders, $dataTypes, ...$args);
} | php | {
"resource": ""
} |
q260450 | DatabaseStrategy.limit | test | public function limit($sqlQuery, $number, ...$args)
{
return $this->uses()->limit($sqlQuery, $number, ...$args);
} | php | {
"resource": ""
} |
q260451 | DatabaseStrategy.tableExists | test | public function tableExists($tableName, $schemaName = null, ...$args)
{
return $this->uses()->tableExists($tableName, $schemaName, ...$args);
} | php | {
"resource": ""
} |
q260452 | DatabaseStrategy.viewExists | test | public function viewExists($viewName, $schemaName = null, ...$args)
{
return $this->uses()->viewExists($viewName, $schemaName, ...$args);
} | php | {
"resource": ""
} |
q260453 | DatabaseStrategy.createTable | test | public function createTable($tableName, $schemaName, array $definition, ...$args)
{
return $this->uses()->createTable($tableName, $schemaName, $definition, ...$args); } | php | {
"resource": ""
} |
q260454 | DatabaseStrategy.createView | test | public function createView($viewName, array $definition, $schemaName = null, ...$args)
{
return $this->uses()->createView($viewName, $definition, $schemaName, ...$args); } | php | {
"resource": ""
} |
q260455 | DatabaseStrategy.dropView | test | public function dropView($viewName, $schemaName = null, $ifExists = true, ...$args)
{
return $this->uses()->dropView($viewName, $schemaName, $ifExists, ...$args);
} | php | {
"resource": ""
} |
q260456 | DatabaseStrategy.addColumn | test | public function addColumn($tableName, $schemaName, ColumnInterface $column, ...$args)
{
return $this->uses()->addColumn($tableName, $schemaName, $column, ...$args); } | php | {
"resource": ""
} |
q260457 | DatabaseStrategy.modifyColumn | test | public function modifyColumn($tableName, $schemaName, ColumnInterface $column, ColumnInterface $currentColumn = null, ...$args)
{
return $this->uses()->modifyColumn($tableName, $schemaName, $column, $currentColumn, ...$args); } | php | {
"resource": ""
} |
q260458 | DatabaseStrategy.dropColumn | test | public function dropColumn($tableName, $schemaName, $columnName, ...$args)
{
return $this->uses()->dropColumn($tableName, $schemaName, $columnName, ...$args);
} | php | {
"resource": ""
} |
q260459 | DatabaseStrategy.addIndex | test | public function addIndex($tableName, $schemaName, IndexInterface $index, ...$args)
{
return $this->uses()->addIndex($tableName, $schemaName, $index, ...$args); } | php | {
"resource": ""
} |
q260460 | DatabaseStrategy.dropIndex | test | public function dropIndex($tableName, $schemaName, $indexName, ...$args)
{
return $this->uses()->dropIndex($tableName, $schemaName, $indexName, ...$args);
} | php | {
"resource": ""
} |
q260461 | DatabaseStrategy.addPrimaryKey | test | public function addPrimaryKey($tableName, $schemaName, IndexInterface $index, ...$args)
{
return $this->uses()->addPrimaryKey($tableName, $schemaName, $index, ...$args); } | php | {
"resource": ""
} |
q260462 | DatabaseStrategy.dropPrimaryKey | test | public function dropPrimaryKey($tableName, $schemaName, ...$args)
{
return $this->uses()->dropPrimaryKey($tableName, $schemaName, ...$args);
} | php | {
"resource": ""
} |
q260463 | DatabaseStrategy.addForeignKey | test | public function addForeignKey($tableName, $schemaName, ReferenceInterface $reference, ...$args)
{
return $this->uses()->addForeignKey($tableName, $schemaName, $reference, ...$args); } | php | {
"resource": ""
} |
q260464 | DatabaseStrategy.dropForeignKey | test | public function dropForeignKey($tableName, $schemaName, $referenceName, ...$args)
{
return $this->uses()->dropForeignKey($tableName, $schemaName, $referenceName, ...$args);
} | php | {
"resource": ""
} |
q260465 | DatabaseStrategy.describeIndexes | test | public function describeIndexes($table, $schema = null, ...$args)
{
return $this->uses()->describeIndexes($table, $schema, ...$args);
} | php | {
"resource": ""
} |
q260466 | DatabaseStrategy.describeReferences | test | public function describeReferences($table, $schema = null, ...$args)
{
return $this->uses()->describeReferences($table, $schema, ...$args);
} | php | {
"resource": ""
} |
q260467 | DatabaseStrategy.tableOptions | test | public function tableOptions($tableName, $schemaName = null, ...$args)
{
return $this->uses()->tableOptions($tableName, $schemaName, ...$args);
} | php | {
"resource": ""
} |
q260468 | QueryPanel.getPanel | test | public function getPanel()
{
$latte = new Latte\Engine;
$latte->addFilter('storageId', [$this, 'getStorageId']);
$latte->addFilter('colorRange', [$this, 'getColorInRange']);
$args = [
'title' => $this->getTitle(),
'collector' => $this->collector,
];
if ($this->collector->getQueries())
{
$this->extremes = $this->collector->getTimeExtremes();
}
return $latte->renderToString(__DIR__ . '/queryPanel.latte', $args);
} | php | {
"resource": ""
} |
q260469 | WrapperTrait.addColumn | test | public function addColumn($tableName, $schemaName, Db\ColumnInterface $column)
{
return $this->dialect->addColumn($tableName, $schemaName, $column);
} | php | {
"resource": ""
} |
q260470 | WrapperTrait.modifyColumn | test | public function modifyColumn(
$tableName,
$schemaName,
Db\ColumnInterface $column,
Db\ColumnInterface $currentColumn = null
)
{
return $this->dialect->modifyColumn($tableName, $schemaName, $column, $currentColumn);
} | php | {
"resource": ""
} |
q260471 | WrapperTrait.dropColumn | test | public function dropColumn($tableName, $schemaName, $columnName)
{
return $this->dialect->dropColumn($tableName, $schemaName, $columnName);
} | php | {
"resource": ""
} |
q260472 | WrapperTrait.dropIndex | test | public function dropIndex($tableName, $schemaName, $indexName)
{
return $this->dialect->dropIndex($tableName, $schemaName, $indexName);
} | php | {
"resource": ""
} |
q260473 | WrapperTrait.addPrimaryKey | test | public function addPrimaryKey($tableName, $schemaName, Db\IndexInterface $index)
{
return $this->dialect->addPrimaryKey($tableName, $schemaName, $index);
} | php | {
"resource": ""
} |
q260474 | WrapperTrait.dropForeignKey | test | public function dropForeignKey($tableName, $schemaName, $referenceName)
{
return $this->dialect->dropForeignKey($tableName, $schemaName, $referenceName);
} | php | {
"resource": ""
} |
q260475 | WrapperTrait.createTable | test | public function createTable($tableName, $schemaName, array $definition)
{
return $this->dialect->createTable($tableName, $schemaName, $definition);
} | php | {
"resource": ""
} |
q260476 | WrapperTrait.createView | test | public function createView($viewName, array $definition, $schemaName = null)
{
return $this->dialect->createView($viewName, $definition, $schemaName);
} | php | {
"resource": ""
} |
q260477 | WrapperTrait.dropTable | test | public function dropTable($tableName, $schemaName = null, $ifExists = null)
{
return $this->dialect->dropTable($tableName, $schemaName, $ifExists);
} | php | {
"resource": ""
} |
q260478 | WrapperTrait.dropView | test | public function dropView($viewName, $schemaName = null, $ifExists = true)
{
return $this->dialect->dropView($viewName, $schemaName, $ifExists);
} | php | {
"resource": ""
} |
q260479 | Application.bindPathsInContainer | test | protected function bindPathsInContainer()
{
parent::bindPathsInContainer();
foreach (['extensions', 'themes', 'assets', 'temp'] as $path) {
$this->instance('path.'.$path, $this->{$path.'Path'}());
}
} | php | {
"resource": ""
} |
q260480 | Application.hasDatabase | test | public function hasDatabase()
{
try {
$hasDatabase = is_null($this->hasDatabase)
? $this['db.connection']->getSchemaBuilder()->hasTable('settings')
: $this->hasDatabase;
}
catch (Exception $ex) {
$hasDatabase = FALSE;
}
return $this->hasDatabase = $hasDatabase;
} | php | {
"resource": ""
} |
q260481 | Logger.register | test | protected function register()
{
/** @var \Phalcon\Config|\stdClass $config */
$config = $this->getDI()->getShared(Services::CONFIG)->log;
$adapter = isset($config->adapter) ? $config->adapter : null;
switch ($adapter) {
case null:
case FileLoggerAdapter::class:
case 'File':
$adapter = FileLoggerAdapter::class;
$name = isset($config->path) ? $config->path : null;
break;
case 'Firelogger':
case 'Stream':
case 'Syslog':
case 'Udplogger':
$adapter = '\Phalcon\Logger\Adapter\\' . ucfirst($adapter);
$name = isset($config->name) ? $config->name : 'phalcon';
break;
default:
if(!class_exists($adapter)){
throw new \RuntimeException("Logger adapter $adapter not implemented.");
}
$name = isset($config->name) ? $config->name : (isset($config->path) ? $config->path : 'phalcon');
}
if (empty($name)) {
throw new \RuntimeException('Required parameter {name|path} missing.');
}
if (empty($config->options)) {
throw new \RuntimeException('Required parameter {options} missing.');
}
return new $adapter($name, (array)$config->options);
} | php | {
"resource": ""
} |
q260482 | NotificationServiceProvider.boot | test | public function boot()
{
$this->loadViewsFrom(__DIR__.'/resources/views', 'notifications');
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/resources/views' => $this->app->resourcePath('views/vendor/notifications'),
], 'laravel-notifications');
}
} | php | {
"resource": ""
} |
q260483 | GuardsAttributes.fillableFromArray | test | protected function fillableFromArray(array $attributes)
{
if (count($this->getFillable()) > 0) {
return array_intersect_key($attributes, array_flip(
array_merge(['fileName'], $this->getFillable())
));
}
return $attributes;
} | php | {
"resource": ""
} |
q260484 | GuardsAttributes.isFillable | test | public function isFillable($key)
{
// File name is always treated as a fillable attribute.
if ($key === 'fileName') {
return TRUE;
}
// If the key is in the "fillable" array, we can of course assume that it's
// a fillable attribute. Otherwise, we will check the guarded array when
// we need to determine if the attribute is black-listed on the model.
if (in_array($key, $this->getFillable())) {
return TRUE;
}
return empty($this->getFillable()) &&
!Str::startsWith($key, '_');
} | php | {
"resource": ""
} |
q260485 | Currency.convert | test | public function convert($amount, $from = null, $to = null, $format = TRUE)
{
// Get currencies involved
$from = $from ?: $this->config('default');
$to = $to ?: $this->getUserCurrency();
// Get exchange rates
$from_rate = $this->getCurrencyProp($from, 'currency_rate');
$to_rate = $this->getCurrencyProp($to, 'currency_rate');
// Skip invalid to currency rates
if ($to_rate === null) {
return null;
}
// Convert amount
$value = $amount * $to_rate * (1 / $from_rate);
// Should the result be formatted?
if ($format === TRUE) {
return $this->format($value, $to);
}
// Return value
return $value;
} | php | {
"resource": ""
} |
q260486 | Currency.isActive | test | public function isActive($code)
{
return $code && (bool)Arr::get($this->getCurrency($code), 'currency_status', FALSE);
} | php | {
"resource": ""
} |
q260487 | Currency.getCurrencies | test | public function getCurrencies()
{
if ($this->currenciesCache === null) {
if (config('app.debug', FALSE) === TRUE) {
$this->currenciesCache = $this->getDriver()->all();
}
else {
$this->currenciesCache = $this->cache->rememberForever('igniter.currency', function () {
return $this->getDriver()->all();
});
}
}
return $this->currenciesCache;
} | php | {
"resource": ""
} |
q260488 | Kernelize.registerModules | test | public function registerModules(array $modules, $merge = false)
{
if (!empty($this->modules) || !empty($modules)) {
parent::registerModules(array_merge($this->modules, $modules), $merge);
}
} | php | {
"resource": ""
} |
q260489 | Kernelize.attach | test | public function attach(Listener $listener)
{
/** @var \Phalcon\Application $this */
$listener->setDI($this->getDI());
$listener->setEventsManager($this->getEventsManager());
$listener->attach();
} | php | {
"resource": ""
} |
q260490 | User.generateResetCode | test | protected function generateResetCode()
{
$random = str_random(42);
while ($this->newQuery()->where('reset_code', $random)->count() > 0) {
$random = str_random(42);
}
return $random;
} | php | {
"resource": ""
} |
q260491 | User.completeResetPassword | test | public function completeResetPassword($code, $password)
{
if (!$this->checkResetPasswordCode($code))
return FALSE;
$this->password = $password;
$this->reset_time = null;
$this->reset_code = null;
return $this->save();
} | php | {
"resource": ""
} |
q260492 | User.checkResetPasswordCode | test | public function checkResetPasswordCode($resetCode)
{
if ($this->reset_code != $resetCode)
return FALSE;
$expiration = self::$resetExpiration;
if ($expiration > 0) {
if (Carbon::now()->gte($this->reset_time->addMinutes($expiration))) {
// Reset password request has expired, so clear code.
$this->clearResetPasswordCode();
return FALSE;
}
}
return TRUE;
} | php | {
"resource": ""
} |
q260493 | User.completeActivation | test | public function completeActivation($activationCode)
{
if ($this->is_activated) {
throw new Exception('User is already active!');
}
if ($activationCode == $this->activation_code) {
$this->activation_code = null;
$this->status = TRUE;
$this->is_activated = TRUE;
$this->date_activated = $this->freshTimestamp();
$this->save();
return TRUE;
}
return FALSE;
} | php | {
"resource": ""
} |
q260494 | QuestionHelper.ask | test | public static function ask(Writer $output, $input, Question $question)
{
if (!isset($input)) {
$input = STDIN;
}
$output->line('');
$response = self::prompt($output, $input, $question);
if (is_null($response) || $response === '') {
return $question->getDefault();
}
return $response;
} | php | {
"resource": ""
} |
q260495 | CurrencyServiceProvider.registerCurrency | test | public function registerCurrency()
{
$this->app->singleton('currency', function ($app) {
$this->app['events']->fire('currency.beforeRegister', [$this]);
return new Currency(
$app->config->get('currency', []),
$app['cache']
);
});
} | php | {
"resource": ""
} |
q260496 | Controller.routeMiddleware | test | protected function routeMiddleware()
{
$router = $this->router;
$dispatcher = $this->dispatcher;
if (!$dispatcher->wasForwarded() && $router->wasMatched()) {
$actionMethod = $dispatcher->getActionName();
$route = $router->getMatchedRoute();
$paths = $route->getPaths();
if (!empty($paths['middleware'])) {
$middlewares = $paths['middleware'];
if (!is_array($middlewares)) {
$middlewares = [$middlewares];
}
foreach ($middlewares as $key => $middleware) {
if (is_int($key)) {
$middlewareClass = $middleware;
$middlewareParams = [];
} else {
$middlewareClass = $key;
$middlewareParams = !is_array($middlewares) ? [$middleware] : $middleware;
}
$this->middleware($middlewareClass, ...$middlewareParams)->only([$actionMethod]);
}
}
}
} | php | {
"resource": ""
} |
q260497 | Controller.middleware | test | protected function middleware($middlewareClass, ...$params)
{
$middleware = new $middlewareClass(static::class, ...$params);
$this->{Services::APP}->attach($middleware);
return $middleware;
} | php | {
"resource": ""
} |
q260498 | Reflexion.getReflectionClass | test | public static function getReflectionClass($class)
{
$class = self::toClassName($class);
if (!isset(self::$cache[$class]['class'])) {
self::$cache[$class]['class'] = new \ReflectionClass($class);
}
return self::$cache[$class]['class'];
} | php | {
"resource": ""
} |
q260499 | Reflexion.set | test | public static function set($object, $property, $value)
{
$property = self::getReflectionProperty($object, $property);
if (is_string($object) || $property->isStatic()) {
if (($declaringClass = $property->getDeclaringClass()->getName()) !== self::toClassName($object)) {
self::getReflectionProperty($declaringClass, $property->getName())->setValue(null, $value);
return;
}
$property->setValue(null, $value);
return;
}
$property->setValue($object, $value);
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.