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) { ...
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 (...
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)); } ...
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]; } } ret...
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...
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...
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 re...
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 ...
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) { ...
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 s...
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; ...
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; ...
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); $or...
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...
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 \InvalidArgumen...
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 = mi...
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 ...
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 ...
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 imple...
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.'); } ...
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->inp...
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; ...
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->pa...
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::currentPageRes...
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['fullM...
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...
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}}', '{...
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', ...
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_...
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->isPe...
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...
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::escap...
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)); ...
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()); } ret...
{@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 ru...
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...
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 ...
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 \Message...
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 (($val...
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';...
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->is...
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...
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...
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'; ...
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]) .$en...
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); ...
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-holder...
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 creatin...
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 upd...
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); ...
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); ...
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 r...
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['...
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($qu...
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( "Expe...
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 DidNotMatchExcepti...
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 e...
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 DidNotMatchExceptio...
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.'); } ...
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(); ...
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,...
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 Inval...
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 ($p...
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", ...
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', 'd...
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) ...
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