sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
protected function compileJoins(Builder $query, $joins)
{
$sql = array();
$query->setBindings(array(), 'join');
foreach ($joins as $join) {
$table = $this->wrapTable($join->table);
$clauses = array();
foreach ($join->clauses as $clause) {
$clauses[] = $this->compileJoinConstraint($clause);
}
foreach ($join->bindings as $binding) {
$query->addBinding($binding, 'join');
}
$clauses[0] = $this->removeLeadingBoolean($clauses[0]);
$clauses = implode(' ', $clauses);
$type = $join->type;
//
$sql[] = "$type join $table on $clauses";
}
return implode(' ', $sql);
} | Compile the "join" portions of the query.
@param \Nova\Database\Query\Builder $query
@param array $joins
@return string | entailment |
protected function compileJoinConstraint(array $clause)
{
$first = $this->wrap($clause['first']);
$second = $clause['where'] ? '?' : $this->wrap($clause['second']);
return "{$clause['boolean']} $first {$clause['operator']} $second";
} | Create a join clause constraint segment.
@param array $clause
@return string | entailment |
protected function compileWheres(Builder $query)
{
$sql = array();
if (is_null($query->wheres)) return '';
foreach ($query->wheres as $where) {
$method = "where{$where['type']}";
$sql[] = $where['boolean'].' '.$this->$method($query, $where);
}
if (count($sql) > 0) {
$sql = implode(' ', $sql);
return 'where '.preg_replace('/and |or /', '', $sql, 1);
}
return '';
} | Compile the "where" portions of the query.
@param \Nova\Database\Query\Builder $query
@return string | entailment |
protected function whereNested(Builder $query, $where)
{
$nested = $where['query'];
return '('.substr($this->compileWheres($nested), 6).')';
} | Compile a nested where clause.
@param \Nova\Database\Query\Builder $query
@param array $where
@return string | entailment |
protected function whereBetween(Builder $query, $where)
{
$between = $where['not'] ? 'not between' : 'between';
return $this->wrap($where['column']).' '.$between.' ? and ?';
} | Compile a "between" where clause.
@param \Nova\Database\Query\Builder $query
@param array $where
@return string | entailment |
protected function whereInSub(Builder $query, $where)
{
$select = $this->compileSelect($where['query']);
return $this->wrap($where['column']).' in ('.$select.')';
} | Compile a where in sub-select clause.
@param \Nova\Database\Query\Builder $query
@param array $where
@return string | entailment |
protected function compileHavings(Builder $query, $havings)
{
$sql = implode(' ', array_map(array($this, 'compileHaving'), $havings));
return 'having '.preg_replace('/and |or /', '', $sql, 1);
} | Compile the "having" portions of the query.
@param \Nova\Database\Query\Builder $query
@param array $havings
@return string | entailment |
protected function restrict()
{
$length = strlen($this->data);
if ($length > 0)
{
$this->data[$length - 1] = chr(ord($this->data[$length - 1]) & self::$restrict[$this->size % 8]);
}
return $this;
} | Remove useless bits for simplifying count operation.
@return BitArray $this for chaining
@since 1.2.0 | entailment |
public function offsetGet($offset)
{
if ($this->offsetExists($offset))
{
return (bool) (ord($this->data[(int) ($offset / 8)]) & (1 << $offset % 8));
}
else
{
throw new \OutOfRangeException('Argument offset must be a positive integer lesser than the size');
}
} | Get the truth value for an index
@param integer $offset The offset
@return boolean The truth value
@throw \OutOfRangeException Argument index must be an positive integer lesser than the size
@since 1.0.0 | entailment |
public function offsetSet($offset, $value)
{
if ($this->offsetExists($offset))
{
$index = (int) ($offset / 8);
if ($value)
{
$this->data[$index] = chr(ord($this->data[$index]) | (1 << $offset % 8));
}
else
{
$this->data[$index] = chr(ord($this->data[$index]) & ~(1 << $offset % 8));
}
}
else
{
throw new \OutOfRangeException('Argument index must be a positive integer lesser than the size');
}
} | Set the truth value for an index
@param integer $offset The offset
@param boolean $value The truth value
@return void
@throw \OutOfRangeException Argument index must be an positive integer lesser than the size
@since 1.0.0 | entailment |
public function count()
{
$count = 0;
for ($index = 0, $length = strlen($this->data); $index < $length; $index++)
{
$count += self::$count[ord($this->data[$index])];
}
return $count;
} | Return the number of true bits
@return integer The number of true bits
@since 1.0.0 | entailment |
public function toArray()
{
$array = array();
for ($index = 0; $index < $this->size; $index++)
{
$array[] = (bool) (ord($this->data[(int) ($index / 8)]) & (1 << $index % 8));
}
return $array;
} | Transform the object to an array
@return array Array of values
@since 1.1.0 | entailment |
public function directCopy(BitArray $bits, $index = 0, $offset = 0, $size = 0)
{
if ($offset > $index)
{
for ($i = 0; $i < $size; $i++)
{
$this[$i + $index] = $bits[$i + $offset];
}
}
else
{
for ($i = $size - 1; $i >= 0; $i--)
{
$this[$i + $index] = $bits[$i + $offset];
}
}
return $this;
} | Copy bits directly from a BitArray
@param BitArray $bits A BitArray to copy
@param int $index Starting index for destination
@param int $offset Starting index for copying
@param int $size Copy size
@return BitArray This object for chaining
@throw \OutOfRangeException Argument index must be an positive integer lesser than the size
@since 1.1.0 | entailment |
public function copy(BitArray $bits, $index = 0, $offset = 0, $size = null)
{
$index = $this->getRealOffset($index);
$offset = $bits->getRealOffset($offset);
$size = $bits->getRealSize($offset, $size);
if ($size > $this->size - $index)
{
$size = $this->size - $index;
}
return $this->directCopy($bits, $index, $offset, $size);
} | Copy bits from a BitArray
@param BitArray $bits A BitArray to copy
@param int $index Starting index for destination.
If index is non-negative, the index parameter is used as it is, keeping its real value between 0 and size-1.
If index is negative, the index parameter starts from the end, keeping its real value between 0 and size-1.
@param int $offset Starting index for copying.
If offset is non-negative, the offset parameter is used as it is, keeping its positive value between 0 and size-1.
If offset is negative, the offset parameter starts from the end, keeping its real value between 0 and size-1.
@param mixed $size Copy size.
If size is given and is positive, then the copy will copy size elements.
If the bits argument is shorter than the size, then only the available elements will be copied.
If size is given and is negative then the copy starts from the end.
If it is omitted, then the copy will have everything from offset up until the end of the bits argument.
@return BitArray This object for chaining
@since 1.1.0 | entailment |
protected function getRealOffset($offset)
{
$offset = (int) $offset;
if ($offset < 0)
{
// Start from the end
$offset = $this->size + $offset;
if ($offset < 0)
{
$offset = 0;
}
}
elseif ($offset > $this->size)
{
$offset = $this->size;
}
return $offset;
} | Get the real offset using a positive or negative offset
@param int $offset If offset is non-negative, the offset parameter is used as it is, keeping its real value between 0 and size-1.
If offset is negative, the offset parameter starts from the end, keeping its real value between 0 and size-1.
@return integer The real offset
@since 1.1.0 | entailment |
protected function getRealSize($offset, $size)
{
if ($size === null)
{
$size = $this->size - $offset;
}
else
{
$size = (int) $size;
if ($size < 0)
{
$size = $this->size + $size - $offset;
if ($size < 0)
{
$size = 0;
}
}
elseif ($size > $this->size - $offset)
{
$size = $this->size - $offset;
}
}
return $size;
} | Get the real offset using a positive or negative offset
@param int $offset The real offset.
@param mixed $size If size is given and is positive, then the real size will be between 0 and the current size-1.
If size is given and is negative then the real size starts from the end.
If it is omitted, then the size goes until the end of the BitArray.
@return integer The real size
@since 1.1.0 | entailment |
public static function fromDecimal($size, $values = 0)
{
$size = min((int) $size, PHP_INT_SIZE);
$values <<= PHP_INT_SIZE - $size;
$bits = new BitArray($size);
for ($i = 0; $i < PHP_INT_SIZE; $i++)
{
$bits->data[$i] = chr(($values & (0xff << (PHP_INT_SIZE - 8))) >> (PHP_INT_SIZE - 8));
$values <<= 8;
}
return $bits;
} | Create a new BitArray from a sequence of bits.
@param integer $size Size of the BitArray
@param integer $values The values for the bits
@return BitArray A new BitArray
@since 1.2.0 | entailment |
public static function fromTraversable($traversable)
{
$bits = new BitArray(count($traversable));
$offset = 0;
$ord = 0;
foreach ($traversable as $value)
{
if ($value)
{
$ord |= 1 << $offset % 8;
}
if ($offset % 8 === 7)
{
$bits->data[(int) ($offset / 8)] = chr($ord);
$ord = 0;
}
$offset++;
}
if ($offset % 8 !== 0)
{
$bits->data[(int) ($offset / 8)] = chr($ord);
}
return $bits;
} | Create a new BitArray from a traversable
@param \Traversable $traversable A traversable and countable
@return BitArray A new BitArray
@since 1.0.0 | entailment |
public static function fromString($string)
{
$bits = new BitArray(strlen($string));
$ord = 0;
for ($offset = 0; $offset < $bits->size; $offset++)
{
if ($string[$offset] !== '0')
{
$ord |= 1 << $offset % 8;
}
if ($offset % 8 === 7)
{
$bits->data[(int) ($offset / 8)] = chr($ord);
$ord = 0;
}
}
if ($offset % 8 !== 0)
{
$bits->data[(int) ($offset / 8)] = chr($ord);
}
return $bits;
} | Create a new BitArray from a bit string
@param string $string A bit string
@return BitArray A new BitArray
@since 1.0.0 | entailment |
public static function fromSlice(BitArray $bits, $offset = 0, $size = null)
{
$offset = $bits->getRealOffset($offset);
$size = $bits->getRealSize($offset, $size);
$slice = new BitArray($size);
return $slice->directCopy($bits, 0, $offset, $size);
} | Create a new BitArray using a slice
@param BitArray $bits A BitArray to get the slice
@param int $offset If offset is non-negative, the slice will start at that offset in the bits argument.
If offset is negative, the slice will start from the end of the bits argument.
@param mixed $size If size is given and is positive, then the slice will have up to that many elements in it.
If the bits argument is shorter than the size, then only the available elements will be present.
If size is given and is negative then the slice will stop that many elements from the end of the bits argument.
If it is omitted, then the slice will have everything from offset up until the end of the bits argument.
@return BitArray A new BitArray
@since 1.1.0 | entailment |
public static function fromConcat(BitArray $bits1, BitArray $bits2)
{
$size = $bits1->size + $bits2->size;
$concat = new BitArray($size);
$concat->directCopy($bits1, 0, 0, $bits1->size);
$concat->directCopy($bits2, $bits1->size, 0, $bits2->size);
return $concat;
} | Create a new BitArray using the concat operation
@param BitArray $bits1 A BitArray
@param BitArray $bits2 A BitArray
@return BitArray A new BitArray
@since 1.1.0 | entailment |
public function applyComplement()
{
$length = strlen($this->data);
for ($index = 0; $index < $length; $index++)
{
$this->data[$index] = chr(~ ord($this->data[$index]));
}
return $this->restrict();
} | Complement the bit array
@return BitArray This object for chaining
@since 1.0.0 | entailment |
public function applyXor(BitArray $bits)
{
if ($this->size == $bits->size)
{
$length = strlen($this->data);
for ($index = 0; $index < $length; $index++)
{
$this->data[$index] = chr(ord($this->data[$index]) ^ ord($bits->data[$index]));
}
return $this;
}
else
{
throw new \InvalidArgumentException('Argument must be of equal size');
}
} | Xor with an another bit array
@param BitArray $bits A bit array
@return BitArray This object for chaining
@throw \InvalidArgumentException Argument must be of equal size
@since 1.0.0 | entailment |
public function shift($size = 1, $value = false)
{
$size = (int) $size;
if ($size > 0)
{
$min = min($this->size, $size);
for ($i = $this->size - 1; $i >= $min; $i--)
{
$this[$i] = $this[$i - $min];
}
for ($i = 0; $i < $min; $i++)
{
$this[$i] = $value;
}
}
else
{
$min = min($this->size, -$size);
for ($i = 0; $i < $this->size - $min; $i++)
{
$this[$i] = $this[$i + $min];
}
for ($i = $this->size - $min; $i < $this->size; $i++)
{
$this[$i] = $value;
}
}
return $this;
} | Shift a bit array.
@param int $size Size to shift.
Negative value means the shifting is done right to left while
positive value means the shifting is done left to right.
@param boolean $value Value to shift
@return BitArray $this for chaining
@since 1.2.0 | entailment |
public function registerTemplateEngine($resolver)
{
$app = $this->app;
// The Compiler engine requires an instance of the CompilerInterface, which in
// this case will be the Template compiler, so we'll first create the compiler
// instance to pass into the engine so it can compile the views properly.
$app->bindShared('template.compiler', function($app)
{
$cachePath = $app['config']['view.compiled'];
return new TemplateCompiler($app['files'], $cachePath);
});
$resolver->register('template', function() use ($app)
{
return new CompilerEngine($app['template.compiler'], $app['files']);
});
} | Register the Template engine implementation.
@param \Nova\View\Engines\EngineResolver $resolver
@return void | entailment |
public function registerMarkdownEngine($resolver)
{
$app = $this->app;
// The Compiler engine requires an instance of the CompilerInterface, which in
// this case will be the Markdown compiler, so we'll first create the compiler
// instance to pass into the engine so it can compile the views properly.
$app->bindShared('markdown.compiler', function($app)
{
$cachePath = $app['config']['view.compiled'];
return new MarkdownCompiler($app['files'], $cachePath);
});
$resolver->register('markdown', function() use ($app)
{
return new CompilerEngine($app['markdown.compiler'], $app['files']);
});
} | Register the Markdown engine implementation.
@param \Nova\View\Engines\EngineResolver $resolver
@return void | entailment |
public function registerFactory()
{
$this->app->bindShared('view', function($app)
{
// Next we need to grab the engine resolver instance that will be used by the
// environment. The resolver will be used by an environment to get each of
// the various engine implementations such as plain PHP or Template engine.
$resolver = $app['view.engine.resolver'];
$finder = $app['view.finder'];
$factory = new Factory($resolver, $finder, $app['events']);
// We will also set the container instance on this view environment since the
// view composers may be classes registered in the container, which allows
// for great testable, flexible composers for the application developer.
$factory->setContainer($app);
$factory->share('app', $app);
return $factory;
});
} | Register the View Factory.
@return void | entailment |
public function registerViewFinder()
{
$this->app->bindShared('view.finder', function($app)
{
$paths = $app['config']->get('view.paths', array());
return new FileViewFinder($app['files'], $paths);
});
} | Register the view finder implementation.
@return void | entailment |
protected function setPdoForType(Connection $connection, $type = null)
{
if ($type == 'read') {
$connection->setPdo($connection->getReadPdo());
} else if ($type == 'write') {
$connection->setReadPdo($connection->getPdo());
}
return $connection;
} | Prepare the read write mode for database connection instance.
@param \Nova\Database\Connection $connection
@param string $type
@return \Nova\Database\Connection | entailment |
public function handle()
{
if (! $this->confirmToProceed()) {
return;
}
$slug = $this->argument('slug');
if (! empty($slug)) {
if (! $this->packages->exists($slug)) {
return $this->error('Package does not exist.');
}
return $this->rollback($slug);
}
foreach ($this->packages->all() as $package) {
$this->comment('Rollback the last migration from Package: ' .$package['name']);
$this->rollback($package['slug']);
}
} | Execute the console command.
@return mixed | entailment |
protected function rollback($slug)
{
if (! $this->packages->exists($slug)) {
return $this->error('Package does not exist.');
}
$this->requireMigrations($slug);
//
$this->migrator->setConnection($this->input->getOption('database'));
$pretend = $this->input->getOption('pretend');
$this->migrator->rollback($pretend, $slug);
//
foreach ($this->migrator->getNotes() as $note) {
if (! $this->option('quiet')) {
$this->line($note);
}
}
} | Run the migration rollback for the specified Package.
@param string $slug
@return mixed | entailment |
public function guest($path, $status = 302, $headers = array(), $secure = null)
{
$this->session->put('url.intended', $this->generator->full());
return $this->to($path, $status, $headers, $secure);
} | Create a new redirect response, while putting the current URL in the session.
@param string $path
@param int $status
@param array $headers
@param bool $secure
@return \Nova\Http\RedirectResponse | entailment |
public function intended($default = '/', $status = 302, $headers = array(), $secure = null)
{
$path = $this->session->pull('url.intended', $default);
return $this->to($path, $status, $headers, $secure);
} | Create a new redirect response to the previously intended location.
@param string $default
@param int $status
@param array $headers
@param bool $secure
@return \Nova\Http\RedirectResponse | entailment |
public function url()
{
if (empty($parameters = func_get_args())) {
return $this->to('/');
}
$path = array_shift($parameters);
$result = preg_replace_callback('#\{(\d+)\}#', function ($matches) use ($parameters)
{
list ($value, $key) = $matches;
return isset($parameters[$key]) ? $parameters[$key] : $value;
}, $path);
return $this->to($path);
} | Create a new redirect response from the given path and arguments.
@return \Nova\Http\RedirectResponse | entailment |
public function to($path, $status = 302, $headers = array(), $secure = null)
{
$path = $this->generator->to($path, array(), $secure);
return $this->createRedirect($path, $status, $headers);
} | Create a new redirect response to the given path.
@param string $path
@param int $status
@param array $headers
@param bool $secure
@return \Nova\Http\RedirectResponse | entailment |
protected function getPath($name)
{
$name = str_replace($this->container->getNamespace(), '', $name);
return $this->container['path'] .DS .str_replace('\\', DS, $name) .'.php';
} | Get the destination class path.
@param string $name
@return string | entailment |
protected function parseName($name)
{
$rootNamespace = $this->container->getNamespace();
if (Str::startsWith($name, $rootNamespace)) {
return $name;
}
if (Str::contains($name, '/')) {
$name = str_replace('/', '\\', $name);
}
return $this->parseName($this->getDefaultNamespace(trim($rootNamespace, '\\')) .'\\' .$name);
} | Parse the name and format according to the root namespace.
@param string $name
@return string | entailment |
protected function replaceNamespace(&$stub, $name)
{
$stub = str_replace('{{namespace}}', $this->getNamespace($name), $stub);
$stub = str_replace('{{rootNamespace}}', $this->container->getNamespace(), $stub);
return $this;
} | Replace the namespace for the given stub.
@param string $stub
@param string $name
@return $this | entailment |
public function register()
{
Paginator::viewFactoryResolver(function ()
{
return $this->app['view'];
});
Paginator::currentPathResolver(function ($pageName = 'page')
{
return $this->app['request']->url();
});
Paginator::currentPageResolver(function ($pageName = 'page')
{
$page = $this->app['request']->input($pageName, 1);
if ((filter_var($page, FILTER_VALIDATE_INT) !== false) && ((int) $page >= 1)) {
return $page;
}
return 1;
});
Paginator::urlGeneratorResolver(function (AbstractPaginator $paginator)
{
return new UrlGenerator($paginator);
});
} | Register the service provider.
@return void | entailment |
protected function resolveByPath($filePath)
{
$this->data['filename'] = $this->makeFileName($filePath);
$this->data['namespace'] = $this->getNamespace($filePath);
$this->data['className'] = basename($filePath);
//
$this->data['model'] = 'dummy';
$this->data['fullModel'] = 'dummy';
$this->data['camelModel'] = 'dummy';
$this->data['pluralModel'] = 'dummy';
$this->data['userModel'] = 'dummy';
$this->data['fullUserModel'] = 'dummy';
} | Resolve Container after getting file path.
@param string $filePath
@return array | entailment |
protected function resolveByOption($option)
{
$model = str_replace('/', '\\', $option);
$namespaceModel = $this->container->getNamespace() .'Models\\' .$model;
if (Str::startsWith($model, '\\')) {
$this->data['fullModel'] = trim($model, '\\');
} else {
$this->data['fullModel'] = $namespaceModel;
}
$this->data['model'] = $model = class_basename(trim($model, '\\'));
$this->data['camelModel'] = Str::camel($model);
$this->data['pluralModel'] = Str::plural(Str::camel($model));
//
$config = $this->container['config'];
$this->data['fullUserModel'] = $model = $config->get('auth.providers.users.model', 'App\Models\User');
$this->data['userModel'] = class_basename(trim($model, '\\'));
} | Resolve Container after getting input option.
@param string $option
@return array | entailment |
protected function formatContent($content)
{
$searches = array(
'{{filename}}',
'{{namespace}}',
'{{className}}',
'{{model}}',
'{{fullModel}}',
'{{camelModel}}',
'{{pluralModel}}',
'{{userModel}}',
'{{fullUserModel}}',
);
$replaces = array(
$this->data['filename'],
$this->data['namespace'],
$this->data['className'],
$this->data['model'],
$this->data['fullModel'],
$this->data['camelModel'],
$this->data['pluralModel'],
$this->data['userModel'],
$this->data['fullUserModel'],
);
$content = str_replace($searches, $replaces, $content);
//
$class = $this->data['fullModel'];
return str_replace("use {$class};\nuse {$class};", "use {$class};", $content);
} | Replace placeholder text with correct values.
@return string | entailment |
public function showAction($slug)
{
$category = $this->getCategoryRepository()->retrieveActiveBySlug($slug);
if (!$category) {
throw $this->createNotFoundException('category doesnt exists');
}
return $this->render(
'GenjFaqBundle:Category:show.html.twig',
array(
'category' => $category
)
);
} | shows questions within 1 category
@param string $slug
@return \Symfony\Component\HttpFoundation\Response | entailment |
public function confirmToProceed($warning = 'Application In Production!', Closure $callback = null)
{
$shouldConfirm = $callback ?: $this->getDefaultConfirmCallback();
if (call_user_func($shouldConfirm))
{
if ($this->option('force')) return true;
$this->comment(str_repeat('*', strlen($warning) + 12));
$this->comment('* '.$warning.' *');
$this->comment(str_repeat('*', strlen($warning) + 12));
$this->output->writeln('');
$confirmed = $this->confirm('Do you really wish to run this command?');
if (! $confirmed) {
$this->comment('Command Cancelled!');
return false;
}
}
return true;
} | Confirm before proceeding with the action
@param string $warning
@param \Closure $callback
@return bool | entailment |
public function getParams(): array
{
$params = [
'inline_query_id' => $this->inlineQueryId,
];
if ($this->cacheTime) {
$params['cache_time'] = $this->cacheTime;
}
if ($this->isPersonal !== null) {
$params['is_personal'] = (int)$this->isPersonal;
}
if ($this->nextOffset) {
$params['next_offset'] = $this->nextOffset;
}
return $params;
} | Get parameters for HTTP query.
@return mixed | entailment |
public function ping()
{
$apiCall = '/helper/ping';
$payload = "";
$data = $this->requestMonkey($apiCall, $payload);
$data = json_decode($data, true);
if (isset($data['error']))
throw new MailchimpAPIException($data);
else
return $data['msg'];
} | Ping the MailChimp API
@return string
@throws MailchimpAPIException | entailment |
public function generateText($type = 'html', $content = array())
{
$apiCall = '/helper/generate-text';
$payload = array(
'type' => $type,
'content' => $content
);
$data = $this->requestMonkey($apiCall, $payload);
$data = json_decode($data, true);
if (isset($data['error']))
throw new MailchimpAPIException($data);
else
return $data;
} | Have HTML content auto-converted to a text-only format. You can send: plain HTML, an existing Campaign Id, or an existing Template Id
@param string $type
@param array $content
@return array
@throws MailchimpAPIException | entailment |
public function call($callback, array $parameters = array())
{
$this->events[] = $event = new CallbackEvent($this->mutex, $callback, $parameters);
return $event;
} | Add a new callback event to the schedule.
@param string $callback
@param array $parameters
@return \Nova\Console\Scheduling\Event | entailment |
public function command($command, array $parameters = array())
{
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
if (defined('HHVM_VERSION')) {
$binary .= ' --php';
}
if (defined('FORGE_BINARY')) {
$forge = ProcessUtils::escapeArgument(FORGE_BINARY);
} else {
$forge = 'forge';
}
return $this->exec("{$binary} {$forge} {$command}", $parameters);
} | Add a new Forge command event to the schedule.
@param string $command
@param array $parameters
@return \Nova\Console\Scheduling\Event | entailment |
protected function compileParameters(array $parameters)
{
return collect($parameters)->map(function ($value, $key)
{
if (is_numeric($key)) {
return $value;
}
return $key .'=' .(is_numeric($value) ? $value : ProcessUtils::escapeArgument($value));
})->implode(' ');
} | Compile parameters for a command.
@param array $parameters
@return string | entailment |
public function dueEvents(Application $app)
{
return array_filter($this->events, function ($event) use ($app)
{
return $event->isDue($app);
});
} | Get all of the events on the schedule that are due.
@param \Nova\Foundation\Application $app
@return array | entailment |
public function attach($file, array $options = array())
{
$attachment = $this->createAttachmentFromPath($file);
return $this->prepAttachment($attachment, $options);
} | Attach a file to the message.
@param string $file
@param array $options
@return $this | entailment |
public function attachData($data, $name, array $options = array())
{
$attachment = $this->createAttachmentFromData($data, $name);
return $this->prepAttachment($attachment, $options);
} | Attach in-memory data as an attachment.
@param string $data
@param string $name
@param array $options
@return $this | entailment |
public function push($filename, LoggerInterface $logger)
{
$logger->info(sprintf('Copying %s to %s', $filename, $this->directory));
$this->filesystem->copy($filename, $this->createPath($filename), true);
return $this->get($filename);
} | {@inheritdoc} | entailment |
public function all()
{
$backups = array();
/** @var SplFileInfo[] $files */
$files = Finder::create()->in($this->directory)->files()->depth(0)->sortByModifiedTime();
foreach ($files as $file) {
$backups[] = Backup::fromFile($file->getPathname());
}
return new BackupCollection($backups);
} | {@inheritdoc} | entailment |
protected function runDown($migration, $pretend)
{
$file = $migration->migration;
// 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($file);
if ($pretend) {
return $this->pretendToRun($instance, 'down');
}
$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->repository->delete($migration);
$this->note("<info>Rolled back:</info> $file");
} | Run "down" a migration instance.
@param object $migration
@param bool $pretend
@return void | entailment |
public function getMigrationFiles($path)
{
$files = $this->files->glob($path .'/*_*.php');
// Once we have the array of files in the directory we will just remove the
// extension and take the basename of the file which is all we need when
// finding the migrations that haven't been run against the databases.
if ($files === false) return array();
$files = array_map(function($file)
{
return str_replace('.php', '', basename($file));
}, $files);
// Once we have all of the formatted file names we will sort them and since
// they all start with a timestamp this should give us the migrations in
// the order they were actually created by the application developers.
sort($files);
return $files;
} | Get all of the migration files in a given path.
@param string $path
@return array | entailment |
public function requireFiles($path, array $files)
{
foreach ($files as $file) {
$this->files->requireOnce($path .DS .$file .'.php');
}
} | Require in all the migration files in a given path.
@param string $path
@param array $files
@return void | entailment |
protected function getQueries($migration, $method)
{
$connection = $migration->getConnection();
// Now that we have the connections we can resolve it and pretend to run the
// queries against the database returning the array of raw SQL statements
// that would get fired against the database system for this migration.
$db = $this->resolveConnection($connection);
return $db->pretend(function() use ($migration, $method)
{
$migration->$method();
});
} | Get all of the queries that would be run for a migration.
@param object $migration
@param string $method
@return array | entailment |
public function handle(TenantIdentified $event)
{
if (!session('tenant')) {
session(['tenant' => $event->tenant->id]);
}
app(Manager::class)->setTenant($event->tenant);
$this->db->createConnection($event->tenant);
} | Handle the event.
@param TenantIdentified $event
@return void | entailment |
public function format($pattern, array $parameters, $language)
{
if (empty($parameters)) {
return $pattern;
}
if (! class_exists('MessageFormatter', false)) {
return $this->fallbackFormat($pattern, $parameters, $language);
}
$formatter = new \MessageFormatter($language, $pattern);
return $formatter->format($parameters);
} | Formats a message via [ICU message format](http://userguide.icu-project.org/formatparse/messages)
If PHP INTL is not installed a fallback will be used that supports a subset of the ICU message format.
@param string $pattern
@param array $params
@param string $language
@return string | entailment |
protected function fallbackFormat($pattern, $parameters, $locale)
{
$tokens = $this->tokenizePattern($pattern);
foreach ($tokens as $key => $token) {
if (! is_array($token)) {
continue;
}
// The token is an ICU command.
else if (($value = $this->parseToken($token, $parameters, $locale)) === false) {
throw new LogicException('Message pattern is invalid.');
}
$tokens[$key] = $value;
}
return implode('', $tokens);
} | Fallback implementation for MessageFormatter::formatMessage
@param string $pattern
@param array $parameters
@param string $locale
@return string | entailment |
private function parseToken($token, $parameters, $locale)
{
$key = trim($token[0]);
if (isset($parameters[$key])) {
$parameter = $parameters[$key];
} else {
return '{' .implode(',', $token) .'}';
}
$type = isset($token[1]) ? trim($token[1]) : 'none';
switch ($type) {
case 'none':
return $parameter;
case 'number':
if (is_integer($parameter) && (! isset($token[2]) || (trim($token[2]) == 'integer'))) {
return $parameter;
}
throw new LogicException("Message format [number] is only supported for integer values.");
break;
case 'date':
case 'time':
case 'spellout':
case 'ordinal':
case 'duration':
case 'choice':
case 'selectordinal':
throw new LogicException("Message format [$type] is not supported.");
};
if (! isset($token[2])) {
return false;
}
$tokens = $this->tokenizePattern($token[2]);
if ($type == 'select') {
$message = $this->parseSelect($tokens, $parameter);
} else if ($type == 'plural') {
$message = $this->parsePlural($tokens, $parameter);
}
if ($message !== false) {
return $this->fallbackFormat($message, $parameters, $locale);
}
return false;
} | Parses a token
@param array $token
@param array $parameters
@param string $locale
@return string
@throws \LogicException | entailment |
public function handle()
{
$config = $this->container['config'];
// Get the Language codes.
$languages = array_keys(
$config->get('languages', array())
);
if ($this->option('path')) {
$path = $this->option('path');
if (! $this->files->isDirectory($path)) {
return $this->error('Not a directory: "' .$path .'"');
} else if (! $this->files->isDirectory($path .DS .'Language')) {
return $this->error('Not a translatable path: "' .$path .'"');
}
return $this->updateLanguageFiles($path, $languages);
}
// Was not specified a custom directory.
else {
$paths = $this->scanWorkPaths($config);
}
// Update the Language files in the available Domains.
foreach ($paths as $path) {
if (! $this->files->isDirectory($path)) {
continue;
} else if (! $this->files->isDirectory($path .DS .'Language')) {
$this->comment('Not a translatable path: "' .$path .'"');
continue;
}
$this->updateLanguageFiles($path, $languages);
}
} | Execute the console command.
@return mixed | entailment |
public function authenticate($method, $arguments)
{
$handlers = $this->filterHandlers($method, $arguments);
if (count($handlers) > 0) {
foreach ($handlers as $handler) {
$isAuthenticated = $handler->authenticate($method, $arguments);
if ($isAuthenticated) {
return;
}
}
throw new InvalidAuth();
} else {
throw new MissingAuth();
}
} | Attempt to authorize a request. This will iterate over all authentication handlers that can handle this type of
request. It will stop after it has found one that can authenticate the request.
@param string $method JSON-RPC method name
@param array $arguments JSON-RPC arguments array (positional or associative)
@throws MissingAuth If the no credentials are given
@throws InvalidAuth If the given credentials are invalid | entailment |
private function filterHandlers($method, $arguments)
{
$handlers = array();
foreach ($this->handlers as $handler) {
if ($handler->canHandle($method, $arguments)) {
$handlers[] = $handler;
}
}
return $handlers;
} | Filters the handlers array down to only the handlers that can handle
the given request.
@param string $method JSON-RPC method name
@param array $arguments JSON-RPC arguments array (positional or associative)
@return Handler[] Filtered list of handlers | entailment |
public function buildResult($result)
{
$updates = [];
foreach ($result as $updateData) {
$update = new Update($updateData);
$updates[] = $update;
$this->lastUpdateId = max($this->lastUpdateId, $update->updateId);
}
return $updates;
} | Build result type from array of data.
@param array $result
@return Update[] | entailment |
public function handle()
{
$name = $this->argument('name');
if (str_contains($name, '\\')) {
$location = $this->filesystem->transformNamespaceToLocation($name);
$filename = $this->filesystem->getFileName($name);
}else {
$location = 'app/Repositories';
$filename = $name;
}
$model = strpos($filename, 'Repository') ? explode('Repository', $filename)[0] : $filename;
if (file_exists($location . '/' . $filename . '.php')) {
return $this->error('Repository already exists');
}
$this->filesystem->makeDirectory(base_path($location), 0755, true, true);
if (config('artify.adr.enabled') && !is_dir(app_path('App/Domain/Contracts'))) {
$contractLocation = app_path('App/Domain/Contracts/');
$repositoryLocation = app_path('App/Domain/Repositories/');
$this->filesystem->makeDirectory($contractLocation, 0755, true, true);
$this->filesystem->makeDirectory($repositoryLocation, 0755, true, true);
}
if (!config('artify.adr.enabled') && !is_dir(app_path('Repositories/Contracts'))) {
$contractLocation = app_path('Repositories/Contracts/');
$repositoryLocation = app_path('Repositories/');
$this->filesystem->makeDirectory($contractLocation, 0755, true, true);
}
if (isset($contractLocation) && !$this->filesystem->exists($contractLocation . 'RepositoryInterface.php')) {
copy(artify_path('artifies/stubs/RepositoryInterface.stub'), $contractLocation . 'RepositoryInterface.php');
}
if (isset($repositoryLocation) && !$this->filesystem->exists($repositoryLocation . 'Repository.php')) {
copy(artify_path('artifies/stubs/Repository.stub'), $repositoryLocation . 'Repository.php');
}
$namespacedModel = config('artify.adr.enabled') ? $this->filesystem->getNamespaceFromLocation(substr($location, 0, strrpos($location, '/'))) . '\\Models\\' . $model : config('artify.models.namespace') . $model;
if ($this->option('model')) {
if (config('artify.adr.enabled')) {
$this->call('make:model',[
'name' => $namespacedModel
]);
}
}
if (config('artify.adr.enabled')) {
$namespacedModel = $namespacedModel . ";\nuse App\\Domain\\Repositories\\Repository";
}
$defaultRepositoryContent = $this->filesystem->get(artify_path('artifies/stubs/DummyRepository.stub'));
$runtimeRepositoryContent = str_replace(['DummyNamespace','DummyModelNamespace', 'DummyRepository', 'Dummy'], [ $this->filesystem->getNamespaceFromLocation($location), $namespacedModel, $filename , ucfirst($model)], $defaultRepositoryContent);
$this->filesystem->put(artify_path('artifies/stubs/DummyRepository.stub'), $runtimeRepositoryContent);
$this->filesystem->copy(artify_path('artifies/stubs/DummyRepository.stub'), $location . '/' . $filename . '.php');
$this->filesystem->put(artify_path('artifies/stubs/DummyRepository.stub'), $defaultRepositoryContent);
$this->info('Yeey! Repository created successfully');
} | Execute the console command.
@return mixed | entailment |
public static function words($value, $words = 100, $end = '...')
{
preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
if (! isset($matches[0]) || (static::length($value) === static::length($matches[0]))) {
return $value;
}
return rtrim($matches[0]) .$end;
} | Limit the number of words in a string.
@param string $value
@param int $words
@param string $end
@return string | entailment |
public static function random($length = 16)
{
$string = '';
while (($len = strlen($string)) < $length) {
$size = $length - $len;
$bytes = static::randomBytes($size);
$string .= substr(str_replace(array('/', '+', '='), '', base64_encode($bytes)), 0, $size);
}
return $string;
} | Generate a more truly "random" alpha-numeric string.
@param int $length
@return string
@throws \RuntimeException | entailment |
public function create($name, $path, $table = null, $create = false)
{
$path = $this->getPath($name, $path);
// First we will get the stub file for the migration, which serves as a type
// of template for the migration. Once we have those we will populate the
// various place-holders, save the file, and run the post create event.
$stub = $this->getStub($table, $create);
$this->files->put($path, $this->populateStub($name, $stub, $table));
$this->firePostCreateHooks();
return $path;
} | Create a new migration at the given path.
@param string $name
@param string $path
@param string $table
@param bool $create
@return string | entailment |
protected function getStub($table, $create)
{
if (is_null($table)) {
return $this->files->get($this->getStubPath() .DS .'blank.stub');
}
// We also have stubs for creating new tables and modifying existing tables
// to save the developer some typing when they are creating a new tables
// or modifying existing tables. We'll grab the appropriate stub here.
else {
$stub = $create ? 'create.stub' : 'update.stub';
return $this->files->get($this->getStubPath() .DS .$stub);
}
} | Get the migration stub file.
@param string $table
@param bool $create
@return string | entailment |
protected function populateStub($name, $stub, $table)
{
$stub = str_replace('{{class}}', $this->getClassName($name), $stub);
// Here we will replace the table place-holders with the table specified by
// the developer, which is useful for quickly creating a tables creation
// or update migration from the console instead of typing it manually.
if (! is_null($table)) {
$stub = str_replace('{{table}}', $table, $stub);
}
return $stub;
} | Populate the place-holders in the migration stub.
@param string $name
@param string $stub
@param string $table
@return string | entailment |
protected function prepareDestination(Closure $callback)
{
return function ($passable) use ($callback)
{
try {
return call_user_func($callback, $passable);
}
catch (Exception $e) {
return $this->handleException($passable, $e);
}
catch (Throwable $e) {
return $this->handleException($passable, new FatalThrowableError($e));
}
};
} | Get the final piece of the Closure onion.
@param \Closure $callback
@return \Closure | entailment |
protected function createSlice($stack, $pipe)
{
return function ($passable) use ($stack, $pipe)
{
try {
return $this->call($pipe, $passable, $stack);
}
catch (Exception $e) {
return $this->handleException($passable, $e);
}
catch (Throwable $e) {
return $this->handleException($passable, new FatalThrowableError($e));
}
};
} | Get a Closure that represents a slice of the application onion.
@param \Closure $stack
@param mixed $pipe
@return \Closure | entailment |
public function register()
{
$this->registerRouter();
$this->registerUrlGenerator();
$this->registerRedirector();
$this->registerResponseFactory();
$this->registerControllerDispatcher();
} | Register the Service Provider.
@return void | entailment |
protected function registerUrlGenerator()
{
$this->app->singleton('url', function ($app)
{
// The URL generator needs the route collection that exists on the router.
// Keep in mind this is an object, so we're passing by references here
// and all the registered routes will be available to the generator.
$routes = $app['router']->getRoutes();
$url = new UrlGenerator($routes, $app->rebinding('request', function ($app, $request)
{
$app['url']->setRequest($request);
}));
$url->setSessionResolver(function ()
{
return $this->app['session'];
});
return $url;
});
} | Register the URL generator service.
@return void | entailment |
public function postUpdate(AdminInterface $admin, $object)
{
$this->create($this->getSubject(), 'sonata.admin.update', [
'target' => $this->getTarget($admin, $object),
'target_text' => $admin->toString($object),
'admin_code' => $admin->getCode(),
]);
} | {@inheritdoc} | entailment |
public function preRemove(AdminInterface $admin, $object)
{
$this->create($this->getSubject(), 'sonata.admin.delete', [
'target_text' => $admin->toString($object),
'admin_code' => $admin->getCode(),
]);
} | {@inheritdoc} | entailment |
protected function getTarget(AdminInterface $admin, $object)
{
return $this->actionManager->findOrCreateComponent($admin->getClass(), $admin->id($object));
} | @param AdminInterface $admin
@param mixed $object
@return ComponentInterface | entailment |
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$httpHandler = $request->getAttribute(AttributeEnum::ROUTER_ATTRIBUTE);
$info = $httpHandler[2];
$actionMiddlewares = [];
if (isset($info['handler']) && \is_string($info['handler'])) {
// Extract action info from router handler
$exploded = explode('@', $info['handler']);
$controllerClass = $exploded[0] ?? '';
$action = $exploded[1] ?? '';
$collector = MiddlewareCollector::getCollector();
$collectedMiddlewares = $collector[$controllerClass]['middlewares']??[];
// Get group middleware from Collector
if ($controllerClass) {
$collect = $collectedMiddlewares['group'] ?? [];
$collect && $actionMiddlewares = array_merge($actionMiddlewares, $collect);
}
// Get the specified action middleware from Collector
if ($action) {
$collect = $collectedMiddlewares['actions'][$action]??[];
$collect && $actionMiddlewares = array_merge($actionMiddlewares, $collect ?? []);
}
}
if (!empty($actionMiddlewares) && $handler instanceof RequestHandler) {
$handler->insertMiddlewares($actionMiddlewares);
}
return $handler->handle($request);
} | do middlewares of action
@param \Psr\Http\Message\ServerRequestInterface $request
@param \Psr\Http\Server\RequestHandlerInterface $handler
@return \Psr\Http\Message\ResponseInterface | entailment |
public function push($job, $data = '', $queue = null)
{
$queueJob = $this->resolveJob($this->createPayload($job, $data, $queue), $queue);
$queueJob->handle();
return 0;
} | Push a new job onto the queue.
@param string $job
@param mixed $data
@param string $queue
@return mixed | entailment |
public function compileSelect(Builder $query)
{
$sql = parent::compileSelect($query);
if ($query->unions) {
$sql = '(' .$sql .') ' .$this->compileUnions($query);
}
return $sql;
} | Compile a select query into SQL.
@param \Nova\Database\Query\Builder
@return string | entailment |
public function compileUpdate(Builder $query, $values)
{
$sql = parent::compileUpdate($query, $values);
if (isset($query->orders)) {
$sql .= ' ' .$this->compileOrders($query, $query->orders);
}
if (isset($query->limit)) {
$sql .= ' ' .$this->compileLimit($query, $query->limit);
}
return rtrim($sql);
} | Compile an update statement into SQL.
@param \Nova\Database\Query\Builder $query
@param array $values
@return string | entailment |
public function doesNotThrow()
{
try {
$this->data[0]();
} catch (Exception $exception) {
if ($this->isKindOfClass($exception, $this->data[1])) {
$exceptionClass = get_class($exception);
throw new DidNotMatchException(
"Expected {$this->data[1]} not to be thrown, " .
"but $exceptionClass was thrown."
);
}
}
} | Assert that a specific exception is not thrown.
@syntax closure ?:callable does not throw ?:class
@throws DidNotMatchException | entailment |
public function throws()
{
try {
$this->data[0]();
} catch (Exception $exception) {
if ($this->isKindOfClass($exception, $this->data[1])) {
return true;
}
$exceptionClass = get_class($exception);
throw new DidNotMatchException(
"Expected {$this->data[1]} to be thrown, " .
"but $exceptionClass was thrown."
);
}
throw new DidNotMatchException(
"Expected {$this->data[1]} to be thrown, but nothing was thrown."
);
} | Assert a specific exception was thrown.
@syntax closure ?:callable throws ?:class
@throws DidNotMatchException | entailment |
public function throwsAnythingExcept()
{
try {
$this->data[0]();
} catch (Exception $exception) {
$exceptionClass = get_class($exception);
if ($exceptionClass === $this->data[1]) {
throw new DidNotMatchException(
"Expected any exception except {$this->data[1]} to be " .
"thrown, but $exceptionClass was thrown."
);
}
}
} | Assert any exception except a specific one was thrown.
@syntax closure ?:callable throws anything except ?:class
@throws DidNotMatchException | entailment |
public function throwsExactly()
{
try {
$this->data[0]();
} catch (Exception $exception) {
$exceptionClass = get_class($exception);
if ($exceptionClass === $this->data[1]) {
return;
} else {
throw new DidNotMatchException(
"Expected exactly {$this->data[1]} to be thrown, " .
"but $exceptionClass was thrown."
);
}
}
throw new DidNotMatchException(
"Expected exactly {$this->data[1]} to be thrown, " .
"but nothing was thrown."
);
} | Assert a specific exception was thrown.
@syntax closure ?:callable throws exactly ?:class
@throws DidNotMatchException | entailment |
public function handle()
{
if (! $this->confirmToProceed()) {
return;
}
$slug = $this->argument('slug');
if (! empty($slug)) {
if (! $this->packages->exists($slug)) {
return $this->error('Package does not exist.');
}
if ($this->packages->isEnabled($slug)) {
$this->seed($slug);
} else if ($this->option('force')) {
$this->seed($slug);
}
return;
}
if ($this->option('force')) {
$packages = $this->packages->all();
} else {
$packages = $this->packages->enabled();
}
foreach ($packages as $package) {
$slug = $package['slug'];
$this->seed($slug);
}
} | Execute the console command.
@return mixed | entailment |
protected function seed($slug)
{
$package = $this->packages->where('slug', $slug);
$className = $package['namespace'] .'\Database\Seeds\DatabaseSeeder';
if (! class_exists($className)) {
return;
}
// Prepare the call parameters.
$params = array();
if ($this->option('class')) {
$params['--class'] = $this->option('class');
} else {
$params['--class'] = $className;
}
if ($option = $this->option('database')) {
$params['--database'] = $option;
}
if ($option = $this->option('force')) {
$params['--force'] = $option;
}
$this->call('db:seed', $params);
} | Seed the specific Package.
@param string $package
@return array | entailment |
public function getParams(): array
{
$params = [
'chat_id' => $this->chatId,
'latitude' => $this->latitude,
'longitude' => $this->longitude,
];
$params = array_merge($params, $this->buildJsonAttributes([
'foursquare_id' => $this->foursquareId,
'disable_notification' => $this->disableNotification,
'reply_to_message_id' => $this->replyToMessageId,
]));
return $params;
} | Get parameters for HTTP query.
@return mixed | entailment |
public function jsonSerialize()
{
$data = [
'title' => $this->title,
'address' => $this->address
];
$data = array_merge($data, $this->buildJsonAttributes([
'reply_markup' => $this->replyMarkup
]));
return $data;
} | Specify data which should be serialized to JSON
@link http://php.net/manual/en/jsonserializable.jsonserialize.php
@return mixed data which can be serialized by <b>json_encode</b>,
which is a value of any type other than a resource.
@since 5.4.0 | entailment |
public function register($assets, $type, $position, $order = 0, $mode = 'default')
{
if (! in_array($type, $this->types)) {
throw new InvalidArgumentException("Invalid assets type [${type}]");
} else if (! in_array($mode, array('default', 'inline', 'view'))) {
throw new InvalidArgumentException("Invalid assets mode [${mode}]");
}
// The assets type and mode are valid.
else if (! empty($items = $this->parseAssets($assets, $order, $mode))) {
// We will merge the items for the specified type and position.
Arr::set($this->positions, $key = "${type}.${position}", array_merge(
Arr::get($this->positions, $key, array()), $items
));
}
} | Register new Assets.
@param string|array $assets
@param string $type
@param string $position
@param int $order
@param string $mode
@return void
@throws \InvalidArgumentException | entailment |
public function position($position, $type)
{
if (! in_array($type, $this->types)) {
throw new InvalidArgumentException("Invalid assets type [${type}]");
}
$positions = is_array($position) ? $position : array($position);
//
$result = array();
foreach ($positions as $position) {
$items = Arr::get($this->positions, "${type}.${position}", array());
if (! empty($items)) {
$result = array_merge($result, $this->renderItems($items, $type, true));
}
}
return implode("\n", array_unique($result));
} | Render the Assets for specified position(s)
@param string|array $position
@param string $type
@return string
@throws \InvalidArgumentException | entailment |
public function render($type, $assets)
{
if (! in_array($type, $this->types)) {
throw new InvalidArgumentException("Invalid assets type [${type}]");
}
// The assets type is valid.
else if (! empty($items = $this->parseAssets($assets))) {
return implode("\n", $this->renderItems($items, $type, false));
}
} | Render the CSS or JS scripts.
@param string $type
@param string|array $assets
@return string|null
@throws \InvalidArgumentException | entailment |
protected function renderItems(array $items, $type, $sorted = true)
{
if ($sorted) {
static::sortItems($items);
}
return array_map(function ($item) use ($type)
{
$asset = Arr::get($item, 'asset');
//
$mode = Arr::get($item, 'mode', 'default');
if ($mode === 'inline') {
$asset = sprintf("\n%s\n", trim($asset));
}
// The 'view' mode is a specialized 'inline'
else if ($mode === 'view') {
$mode = 'inline';
$asset = $this->views->fetch($asset);
}
$template = Arr::get(static::$templates, "${mode}.${type}");
return sprintf($template, $asset);
}, $items);
} | Render the given position items to an array of assets.
@param array $items
@param string $type
@param bool $sorted
@return array | entailment |
protected static function sortItems(array &$items)
{
usort($items, function ($a, $b)
{
if ($a['order'] === $b['order']) {
return 0;
}
return ($a['order'] < $b['order']) ? -1 : 1;
});
} | Sort the given items by their order.
@param array $items
@return void | entailment |
protected function parseAssets($assets, $order = 0, $mode = 'default')
{
if (is_string($assets) && ! empty($assets)) {
$assets = array($assets);
} else if (! is_array($assets)) {
return array();
}
return array_map(function ($asset) use ($order, $mode)
{
return compact('asset', 'order', 'mode');
}, array_filter($assets, function ($value)
{
return ! empty($value);
}));
} | Parses and returns the given assets.
@param string|array $assets
@param int $order
@param string $mode
@return array | entailment |
protected function runCallable()
{
$callable = $this->action['uses'];
$parameters = $this->resolveMethodDependencies(
$this->parametersWithoutNulls(), new ReflectionFunction($callable)
);
return call_user_func_array($callable, $parameters);
} | Run the route action and return the response.
@return mixed | entailment |
public function getController()
{
if (! isset($this->controller)) {
list ($controller, $this->method) = $this->parseControllerCallback();
return $this->controller = $this->container->make($controller);
}
return $this->controller;
} | Get the controller instance for the route.
@return mixed | entailment |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.