_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q13600
CacheableRepository.serializeCriteria
train
protected function serializeCriteria() { try { return serialize($this->getCriteria()); } catch (Exception $e) { return serialize($this->getCriteria()->map(function ($criterion) { return $this->serializeCriterion($criterion); })); } }
php
{ "resource": "" }
q13601
CacheableRepository.serializeCriterion
train
protected function serializeCriterion($criterion) { try { serialize($criterion); return $criterion; } catch (Exception $e) { // We want to take care of the closure serialization errors, // other than that we will simply re-throw the exception. ...
php
{ "resource": "" }
q13602
ComparesVersionsTrait.versionCompare
train
public function versionCompare($frameworkVersion, $compareVersion, $operator = null) { // Lumen (5.5.2) (Laravel Components 5.5.*) $lumenPattern = '/Lumen \((\d\.\d\.[\d|\*])\)( \(Laravel Components (\d\.\d\.[\d|\*])\))?/'; if (preg_match($lumenPattern, $frameworkVersion, $matches)) { ...
php
{ "resource": "" }
q13603
ValidatorGenerator.getRules
train
public function getRules() { if (!$this->rules) { return '[]'; } $results = '[' . PHP_EOL; foreach ($this->getSchemaParser()->toArray() as $column => $value) { $results .= "\t\t'{$column}'\t=>'\t{$value}'," . PHP_EOL; } return $results . "\t"...
php
{ "resource": "" }
q13604
ControllerGenerator.getValidator
train
public function getValidator() { $validatorGenerator = new ValidatorGenerator([ 'name' => $this->name, ]); $validator = $validatorGenerator->getRootNamespace() . '\\' . $validatorGenerator->getName(); return 'use ' . str_replace([ "\\", '/' ...
php
{ "resource": "" }
q13605
ControllerGenerator.getRepository
train
public function getRepository() { $repositoryGenerator = new RepositoryInterfaceGenerator([ 'name' => $this->name, ]); $repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName(); return 'use ' . str_replace([ "\\", ...
php
{ "resource": "" }
q13606
BindingsGenerator.getEloquentRepository
train
public function getEloquentRepository() { $repositoryGenerator = new RepositoryEloquentGenerator([ 'name' => $this->name, ]); $repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName(); return str_replace([ "\\", ...
php
{ "resource": "" }
q13607
BaseRepository.validator
train
public function validator() { if (isset($this->rules) && !is_null($this->rules) && is_array($this->rules) && !empty($this->rules)) { if (class_exists('Prettus\Validator\LaravelValidator')) { $validator = app('Prettus\Validator\LaravelValidator'); if ($validator i...
php
{ "resource": "" }
q13608
BaseRepository.first
train
public function first($columns = ['*']) { $this->applyCriteria(); $this->applyScope(); $results = $this->model->first($columns); $this->resetModel(); return $this->parserResult($results); }
php
{ "resource": "" }
q13609
BaseRepository.find
train
public function find($id, $columns = ['*']) { $this->applyCriteria(); $this->applyScope(); $model = $this->model->findOrFail($id, $columns); $this->resetModel(); return $this->parserResult($model); }
php
{ "resource": "" }
q13610
BaseRepository.findWhereIn
train
public function findWhereIn($field, array $values, $columns = ['*']) { $this->applyCriteria(); $this->applyScope(); $model = $this->model->whereIn($field, $values)->get($columns); $this->resetModel(); return $this->parserResult($model); }
php
{ "resource": "" }
q13611
BaseRepository.findWhereNotIn
train
public function findWhereNotIn($field, array $values, $columns = ['*']) { $this->applyCriteria(); $this->applyScope(); $model = $this->model->whereNotIn($field, $values)->get($columns); $this->resetModel(); return $this->parserResult($model); }
php
{ "resource": "" }
q13612
BaseRepository.whereHas
train
public function whereHas($relation, $closure) { $this->model = $this->model->whereHas($relation, $closure); return $this; }
php
{ "resource": "" }
q13613
BaseRepository.pushCriteria
train
public function pushCriteria($criteria) { if (is_string($criteria)) { $criteria = new $criteria; } if (!$criteria instanceof CriteriaInterface) { throw new RepositoryException("Class " . get_class($criteria) . " must be an instance of Prettus\\Repository\\Contracts\\C...
php
{ "resource": "" }
q13614
BaseRepository.applyConditions
train
protected function applyConditions(array $where) { foreach ($where as $field => $value) { if (is_array($value)) { list($field, $condition, $val) = $value; $this->model = $this->model->where($field, $condition, $val); } else { $this->mod...
php
{ "resource": "" }
q13615
BaseRepository.parserResult
train
public function parserResult($result) { if ($this->presenter instanceof PresenterInterface) { if ($result instanceof Collection || $result instanceof LengthAwarePaginator) { $result->each(function ($model) { if ($model instanceof Presentable) { ...
php
{ "resource": "" }
q13616
Generator.getName
train
public function getName() { $name = $this->name; if (str_contains($this->name, '\\')) { $name = str_replace('\\', '/', $this->name); } if (str_contains($this->name, '/')) { $name = str_replace('/', '/', $this->name); } return Str::studly(str_r...
php
{ "resource": "" }
q13617
Generator.getConfigGeneratorClassPath
train
public function getConfigGeneratorClassPath($class, $directoryPath = false) { switch ($class) { case ('models' === $class): $path = config('repository.generator.paths.models', 'Entities'); break; case ('repositories' === $class): $path ...
php
{ "resource": "" }
q13618
BackupJob.dumpDatabases
train
protected function dumpDatabases(): array { return $this->dbDumpers->map(function (DbDumper $dbDumper, $key) { consoleOutput()->info("Dumping database {$dbDumper->getDbName()}..."); $dbType = mb_strtolower(basename(str_replace('\\', '/', get_class($dbDumper)))); $dbName...
php
{ "resource": "" }
q13619
FileSelection.excludeFilesFrom
train
public function excludeFilesFrom($excludeFilesAndDirectories): self { $this->excludeFilesAndDirectories = $this->excludeFilesAndDirectories->merge($this->sanitize($excludeFilesAndDirectories)); return $this; }
php
{ "resource": "" }
q13620
AMQPWriter.write_bits
train
public function write_bits($bits) { $value = 0; foreach ($bits as $n => $bit) { $bit = $bit ? 1 : 0; $value |= ($bit << $n); } $this->out .= chr($value); return $this; }
php
{ "resource": "" }
q13621
AMQPWriter.write_octet
train
public function write_octet($n) { if ($n < 0 || $n > 255) { throw new AMQPInvalidArgumentException('Octet out of range: ' . $n); } $this->out .= chr($n); return $this; }
php
{ "resource": "" }
q13622
AMQPWriter.write_short
train
public function write_short($n) { if ($n < 0 || $n > 65535) { throw new AMQPInvalidArgumentException('Short out of range: ' . $n); } $this->out .= pack('n', $n); return $this; }
php
{ "resource": "" }
q13623
AMQPWriter.write_long
train
public function write_long($n) { if (($n < 0) || ($n > 4294967295)) { throw new AMQPInvalidArgumentException('Long out of range: ' . $n); } //Numeric strings >PHP_INT_MAX on 32bit are casted to PHP_INT_MAX, damn PHP if (empty($this->is64bits) && is_string($n)) { ...
php
{ "resource": "" }
q13624
AMQPWriter.write_longlong
train
public function write_longlong($n) { if ($n < 0) { throw new AMQPInvalidArgumentException('Longlong out of range: ' . $n); } // if PHP_INT_MAX is big enough for that // direct $n<=PHP_INT_MAX check is unreliable on 64bit (values close to max) due to limited float precisi...
php
{ "resource": "" }
q13625
AMQPWriter.write_shortstr
train
public function write_shortstr($s) { $len = mb_strlen($s, 'ASCII'); if ($len > 255) { throw new AMQPInvalidArgumentException('String too long'); } $this->write_octet($len); $this->out .= $s; return $this; }
php
{ "resource": "" }
q13626
AbstractChannel.prepare_method_frame
train
protected function prepare_method_frame($method_sig, $args = '', $pkt = null) { return $this->connection->prepare_channel_method_frame($this->channel_id, $method_sig, $args, $pkt); }
php
{ "resource": "" }
q13627
AbstractChannel.wait
train
public function wait($allowed_methods = null, $non_blocking = false, $timeout = 0) { $this->debug->debug_allowed_methods($allowed_methods); $deferred = $this->process_deferred_methods($allowed_methods); if ($deferred['dispatch'] === true) { return $this->dispatch_deferred_method...
php
{ "resource": "" }
q13628
GenericContent.has
train
public function has($name) { return isset($this->properties[$name]) || isset($this->delivery_info[$name]); }
php
{ "resource": "" }
q13629
GenericContent.get
train
public function get($name) { if (isset($this->properties[$name])) { return $this->properties[$name]; } if (isset($this->delivery_info[$name])) { return $this->delivery_info[$name]; } throw new \OutOfBoundsException(sprintf( 'No "%s" prope...
php
{ "resource": "" }
q13630
AbstractIO.write_heartbeat
train
protected function write_heartbeat() { $pkt = new AMQPWriter(); $pkt->write_octet(8); $pkt->write_short(0); $pkt->write_long(0); $pkt->write_octet(0xCE); $this->write($pkt->getvalue()); }
php
{ "resource": "" }
q13631
AbstractIO.cleanup_error_handler
train
protected function cleanup_error_handler() { restore_error_handler(); if ($this->last_error !== null) { throw new \ErrorException( $this->last_error['errstr'], 0, $this->last_error['errno'], $this->last_error['errfile'], ...
php
{ "resource": "" }
q13632
AbstractIO.error_handler
train
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = null) { // throwing an exception in an error handler will halt execution // set the last error and continue $this->last_error = compact('errno', 'errstr', 'errfile', 'errline', 'errcontext'); }
php
{ "resource": "" }
q13633
AMQPReader.reuse
train
public function reuse($str) { $this->str = $str; $this->str_length = mb_strlen($this->str, 'ASCII'); $this->offset = 0; $this->bitcount = $this->bits = 0; }
php
{ "resource": "" }
q13634
AMQPReader.wait
train
protected function wait() { $timeout = $this->getTimeout(); if (null === $timeout) { // timeout=null just poll state and return instantly $sec = 0; $usec = 0; } elseif ($timeout > 0) { list($sec, $usec) = MiscHelper::splitSecondsMicroseconds($t...
php
{ "resource": "" }
q13635
AMQPReader.read_longlong
train
public function read_longlong() { $this->bitcount = $this->bits = 0; list(, $hi, $lo) = unpack('N2', $this->rawread(8)); $msb = self::getLongMSB($hi); if (empty($this->is64bits)) { if ($msb) { $hi = sprintf('%u', $hi); } if (self:...
php
{ "resource": "" }
q13636
AMQPReader.read_array
train
public function read_array($returnObject = false) { $this->bitcount = $this->bits = 0; // Determine array length and its end position $arrayLength = $this->read_php_int(); $endOffset = $this->offset + $arrayLength; $result = $returnObject ? new AMQPArray() : array(); ...
php
{ "resource": "" }
q13637
AMQPReader.read_value
train
public function read_value($fieldType, $collectionsAsObjects = false) { $this->bitcount = $this->bits = 0; switch ($fieldType) { case AMQPAbstractCollection::T_INT_SHORTSHORT: //according to AMQP091 spec, 'b' is not bit, it is short-short-int, also valid for rabbit/qpid ...
php
{ "resource": "" }
q13638
AbstractConnection.connect
train
protected function connect() { try { // Loop until we connect while (!$this->isConnected()) { // Assume we will connect, until we dont $this->setIsConnected(true); // Connect the socket $this->io->connect(); ...
php
{ "resource": "" }
q13639
AbstractConnection.reconnect
train
public function reconnect() { // Try to close the AMQP connection $this->safeClose(); // Reconnect the socket/stream then AMQP $this->io->close(); $this->setIsConnected(false); // getIO can initiate the connection setting via LazyConnection, set it here to be sure $th...
php
{ "resource": "" }
q13640
AbstractConnection.safeClose
train
protected function safeClose() { try { if (isset($this->input) && $this->input) { $this->close(); } } catch (\Exception $e) { // Nothing here } }
php
{ "resource": "" }
q13641
AbstractConnection.wait_frame
train
protected function wait_frame($timeout = 0) { if (is_null($this->input)) { $this->setIsConnected(false); throw new AMQPConnectionClosedException('Broken pipe or closed connection'); } $currentTimeout = $this->input->getTimeout(); $this->input->setTime...
php
{ "resource": "" }
q13642
AbstractConnection.wait_channel
train
protected function wait_channel($channel_id, $timeout = 0) { // Keeping the original timeout unchanged. $_timeout = $timeout; while (true) { $now = time(); try { list($frame_type, $frame_channel, $payload) = $this->wait_frame($_timeout); } ...
php
{ "resource": "" }
q13643
AbstractConnection.close
train
public function close($reply_code = 0, $reply_text = '', $method_sig = array(0, 0)) { $result = null; $this->io->disableHeartbeat(); if (empty($this->protocolWriter) || !$this->isConnected()) { return $result; } try { $this->closeChannels(); ...
php
{ "resource": "" }
q13644
AbstractConnection.connection_open_ok
train
protected function connection_open_ok($args) { $this->known_hosts = $args->read_shortstr(); $this->debug->debug_msg('Open OK! known_hosts: ' . $this->known_hosts); }
php
{ "resource": "" }
q13645
AbstractConnection.connection_redirect
train
protected function connection_redirect($args) { $host = $args->read_shortstr(); $this->known_hosts = $args->read_shortstr(); $this->debug->debug_msg(sprintf( 'Redirected to [%s], known_hosts [%s]', $host, $this->known_hosts )); ...
php
{ "resource": "" }
q13646
AbstractConnection.x_secure_ok
train
protected function x_secure_ok($response) { $args = new AMQPWriter(); $args->write_longstr($response); $this->send_method_frame(array(10, 21), $args); }
php
{ "resource": "" }
q13647
AbstractConnection.connection_start
train
protected function connection_start($args) { $this->version_major = $args->read_octet(); $this->version_minor = $args->read_octet(); $this->server_properties = $args->read_table(); $this->mechanisms = explode(' ', $args->read_longstr()); $this->locales = explode(' ', $args->r...
php
{ "resource": "" }
q13648
AbstractConnection.connection_tune
train
protected function connection_tune($args) { $v = $args->read_short(); if ($v) { $this->channel_max = $v; } $v = $args->read_long(); if ($v) { $this->frame_max = $v; } // use server proposed value if not set if ($this->heartbea...
php
{ "resource": "" }
q13649
AbstractConnection.x_tune_ok
train
protected function x_tune_ok($channel_max, $frame_max, $heartbeat) { $args = new AMQPWriter(); $args->write_short($channel_max); $args->write_long($frame_max); $args->write_short($heartbeat); $this->send_method_frame(array(10, 31), $args); $this->wait_tune_ok = false;...
php
{ "resource": "" }
q13650
AbstractConnection.closeChannels
train
protected function closeChannels() { foreach ($this->channels as $key => $channel) { // channels[0] is this connection object, so don't close it yet if ($key === 0) { continue; } try { $channel->close(); } catch (\Ex...
php
{ "resource": "" }
q13651
AMQPChannel.channel_alert
train
protected function channel_alert($reader) { $reply_code = $reader->read_short(); $reply_text = $reader->read_shortstr(); $details = $reader->read_table(); array_push($this->alerts, array($reply_code, $reply_text, $details)); }
php
{ "resource": "" }
q13652
AMQPChannel.close
train
public function close($reply_code = 0, $reply_text = '', $method_sig = array(0, 0)) { $this->callbacks = array(); if ($this->is_open === false || $this->connection === null) { $this->do_close(); return null; // already closed } list($class_id, $method_id, $ar...
php
{ "resource": "" }
q13653
AMQPChannel.access_request
train
public function access_request( $realm, $exclusive = false, $passive = false, $active = false, $write = false, $read = false ) { list($class_id, $method_id, $args) = $this->protocolWriter->accessRequest( $realm, $exclusive, ...
php
{ "resource": "" }
q13654
AMQPChannel.exchange_delete
train
public function exchange_delete( $exchange, $if_unused = false, $nowait = false, $ticket = null ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->exchangeDelete( $ticket, $exchange, ...
php
{ "resource": "" }
q13655
AMQPChannel.exchange_bind
train
public function exchange_bind( $destination, $source, $routing_key = '', $nowait = false, $arguments = array(), $ticket = null ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->exchangeBind( ...
php
{ "resource": "" }
q13656
AMQPChannel.queue_bind
train
public function queue_bind( $queue, $exchange, $routing_key = '', $nowait = false, $arguments = array(), $ticket = null ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->queueBind( $ticket...
php
{ "resource": "" }
q13657
AMQPChannel.queue_unbind
train
public function queue_unbind( $queue, $exchange, $routing_key = '', $arguments = array(), $ticket = null ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->queueUnbind( $ticket, $queue,...
php
{ "resource": "" }
q13658
AMQPChannel.queue_declare_ok
train
protected function queue_declare_ok($reader) { $queue = $reader->read_shortstr(); $message_count = $reader->read_long(); $consumer_count = $reader->read_long(); return array($queue, $message_count, $consumer_count); }
php
{ "resource": "" }
q13659
AMQPChannel.queue_delete
train
public function queue_delete($queue = '', $if_unused = false, $if_empty = false, $nowait = false, $ticket = null) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->queueDelete( $ticket, $queue, $if_unused, ...
php
{ "resource": "" }
q13660
AMQPChannel.queue_purge
train
public function queue_purge($queue = '', $nowait = false, $ticket = null) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->queuePurge($ticket, $queue, $nowait); $this->send_method_frame(array($class_id, $method_id), $args); if ($now...
php
{ "resource": "" }
q13661
AMQPChannel.basic_ack
train
public function basic_ack($delivery_tag, $multiple = false) { list($class_id, $method_id, $args) = $this->protocolWriter->basicAck($delivery_tag, $multiple); $this->send_method_frame(array($class_id, $method_id), $args); }
php
{ "resource": "" }
q13662
AMQPChannel.basic_ack_from_server
train
protected function basic_ack_from_server(AMQPReader $reader) { $delivery_tag = $reader->read_longlong(); $multiple = (bool) $reader->read_bit(); if (!isset($this->published_messages[$delivery_tag])) { throw new AMQPRuntimeException(sprintf( 'Server ack\'ed unknow...
php
{ "resource": "" }
q13663
AMQPChannel.basic_nack_from_server
train
protected function basic_nack_from_server($reader) { $delivery_tag = $reader->read_longlong(); $multiple = (bool) $reader->read_bit(); if (!isset($this->published_messages[$delivery_tag])) { throw new AMQPRuntimeException(sprintf( 'Server nack\'ed unknown deliver...
php
{ "resource": "" }
q13664
AMQPChannel.basic_nack
train
public function basic_nack($delivery_tag, $multiple = false, $requeue = false) { list($class_id, $method_id, $args) = $this->protocolWriter->basicNack($delivery_tag, $multiple, $requeue); $this->send_method_frame(array($class_id, $method_id), $args); }
php
{ "resource": "" }
q13665
AMQPChannel.basic_cancel
train
public function basic_cancel($consumer_tag, $nowait = false, $noreturn = false) { list($class_id, $method_id, $args) = $this->protocolWriter->basicCancel($consumer_tag, $nowait); $this->send_method_frame(array($class_id, $method_id), $args); if ($nowait || $noreturn) { unset($th...
php
{ "resource": "" }
q13666
AMQPChannel.basic_consume
train
public function basic_consume( $queue = '', $consumer_tag = '', $no_local = false, $no_ack = false, $exclusive = false, $nowait = false, $callback = null, $ticket = null, $arguments = array() ) { $ticket = $this->getTicket($ticket); ...
php
{ "resource": "" }
q13667
AMQPChannel.basic_deliver
train
protected function basic_deliver($reader, $message) { $consumer_tag = $reader->read_shortstr(); $delivery_tag = $reader->read_longlong(); $redelivered = $reader->read_bit(); $exchange = $reader->read_shortstr(); $routing_key = $reader->read_shortstr(); $message->deli...
php
{ "resource": "" }
q13668
AMQPChannel.basic_get
train
public function basic_get($queue = '', $no_ack = false, $ticket = null) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->basicGet($ticket, $queue, $no_ack); $this->send_method_frame(array($class_id, $method_id), $args); return $this...
php
{ "resource": "" }
q13669
AMQPChannel.basic_get_ok
train
protected function basic_get_ok($reader, $message) { $delivery_tag = $reader->read_longlong(); $redelivered = $reader->read_bit(); $exchange = $reader->read_shortstr(); $routing_key = $reader->read_shortstr(); $message_count = $reader->read_long(); $message->delivery...
php
{ "resource": "" }
q13670
AMQPChannel.basic_publish
train
public function basic_publish( $msg, $exchange = '', $routing_key = '', $mandatory = false, $immediate = false, $ticket = null ) { $pkt = new AMQPWriter(); $pkt->write($this->pre_publish($exchange, $routing_key, $mandatory, $immediate, $ticket)); ...
php
{ "resource": "" }
q13671
AMQPChannel.basic_recover
train
public function basic_recover($requeue = false) { list($class_id, $method_id, $args) = $this->protocolWriter->basicRecover($requeue); $this->send_method_frame(array($class_id, $method_id), $args); return $this->wait(array( $this->waitHelper->get_wait('basic.recover_ok') ...
php
{ "resource": "" }
q13672
AMQPChannel.basic_reject
train
public function basic_reject($delivery_tag, $requeue) { list($class_id, $method_id, $args) = $this->protocolWriter->basicReject($delivery_tag, $requeue); $this->send_method_frame(array($class_id, $method_id), $args); }
php
{ "resource": "" }
q13673
AMQPChannel.basic_return
train
protected function basic_return($reader, $message) { $callback = $this->basic_return_callback; if (!is_callable($callback)) { $this->debug->debug_msg('Skipping unhandled basic_return message'); return null; } $reply_code = $reader->read_short(); $repl...
php
{ "resource": "" }
q13674
AMQPChannel.tx_rollback
train
public function tx_rollback() { $this->send_method_frame(array(90, 30)); return $this->wait(array( $this->waitHelper->get_wait('tx.rollback_ok') ), false, $this->channel_rpc_timeout); }
php
{ "resource": "" }
q13675
AMQPChannel.confirm_select
train
public function confirm_select($nowait = false) { list($class_id, $method_id, $args) = $this->protocolWriter->confirmSelect($nowait); $this->send_method_frame(array($class_id, $method_id), $args); if ($nowait) { return null; } $this->wait(array( $th...
php
{ "resource": "" }
q13676
AMQPChannel.wait_for_pending_acks
train
public function wait_for_pending_acks($timeout = 0) { $functions = array( $this->waitHelper->get_wait('basic.ack'), $this->waitHelper->get_wait('basic.nack'), ); while (count($this->published_messages) !== 0) { if ($timeout > 0) { $this->w...
php
{ "resource": "" }
q13677
AMQPChannel.tx_select
train
public function tx_select() { $this->send_method_frame(array(90, 10)); return $this->wait(array( $this->waitHelper->get_wait('tx.select_ok') ), false, $this->channel_rpc_timeout); }
php
{ "resource": "" }
q13678
AMQPChannel.set_return_listener
train
public function set_return_listener($callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf( 'Given callback "%s" should be callable. %s type was given.', $callback, gettype($callback) )); } ...
php
{ "resource": "" }
q13679
AMQPChannel.set_nack_handler
train
public function set_nack_handler($callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf( 'Given callback "%s" should be callable. %s type was given.', $callback, gettype($callback) )); } ...
php
{ "resource": "" }
q13680
AMQPChannel.set_ack_handler
train
public function set_ack_handler($callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf( 'Given callback "%s" should be callable. %s type was given.', $callback, gettype($callback) )); } ...
php
{ "resource": "" }
q13681
Consumer.start
train
public function start() { if ($this->restart) { echo 'Restarting consumer.' . PHP_EOL; $this->restart = false; } else { echo 'Starting consumer.' . PHP_EOL; } $exchange = 'router'; $queue = 'msgs'; $this->channel = $this->conne...
php
{ "resource": "" }
q13682
MiscHelper.hexdump
train
public static function hexdump($data, $htmloutput = true, $uppercase = false, $return = false) { // Init $hexi = ''; $ascii = ''; $dump = $htmloutput ? '<pre>' : ''; $offset = 0; $len = mb_strlen($data, 'ASCII'); // Upper or lower case hexidecimal $he...
php
{ "resource": "" }
q13683
Discussion.getApiDocument
train
protected function getApiDocument(User $actor, array $params) { $response = $this->api->send('Flarum\Api\Controller\ShowDiscussionController', $actor, $params); $statusCode = $response->getStatusCode(); if ($statusCode === 404) { throw new RouteNotFoundException; } ...
php
{ "resource": "" }
q13684
Application.url
train
public function url($path = null) { $config = $this->make('flarum.config'); $url = array_get($config, 'url', array_get($_SERVER, 'REQUEST_URI')); if (is_array($url)) { if (isset($url[$path])) { return $url[$path]; } $url = $url['base']; ...
php
{ "resource": "" }
q13685
NotificationServiceProvider.registerNotificationTypes
train
public function registerNotificationTypes() { $blueprints = [ DiscussionRenamedBlueprint::class => ['alert'] ]; $this->app->make('events')->fire( new ConfigureNotificationTypes($blueprints) ); foreach ($blueprints as $blueprint => $enabled) { ...
php
{ "resource": "" }
q13686
RevisionCompiler.getFilenameForRevision
train
protected function getFilenameForRevision(string $revision): string { $ext = pathinfo($this->filename, PATHINFO_EXTENSION); return substr_replace($this->filename, '-'.$revision, -strlen($ext) - 1, 0); }
php
{ "resource": "" }
q13687
NotificationRepository.findByUser
train
public function findByUser(User $user, $limit = null, $offset = 0) { $primaries = Notification::select( app('flarum.db')->raw('MAX(id) AS id'), app('flarum.db')->raw('SUM(read_at IS NULL) AS unread_count') ) ->where('user_id', $user->id) ->whereIn('typ...
php
{ "resource": "" }
q13688
NotificationRepository.markAllAsRead
train
public function markAllAsRead(User $user) { Notification::where('user_id', $user->id)->update(['read_at' => Carbon::now()]); }
php
{ "resource": "" }
q13689
AccessToken.generate
train
public static function generate($userId, $lifetime = 3600) { $token = new static; $token->token = str_random(40); $token->user_id = $userId; $token->created_at = Carbon::now(); $token->last_activity_at = Carbon::now(); $token->lifetime_seconds = $lifetime; r...
php
{ "resource": "" }
q13690
RouteCollectionUrlGenerator.route
train
public function route($name, $parameters = []) { $path = $this->routes->getPath($name, $parameters); $path = ltrim($path, '/'); return $this->baseUrl.'/'.$path; }
php
{ "resource": "" }
q13691
AbstractValidator.assertValid
train
public function assertValid(array $attributes) { $validator = $this->makeValidator($attributes); if ($validator->fails()) { throw new ValidationException($validator); } }
php
{ "resource": "" }
q13692
AbstractValidator.makeValidator
train
protected function makeValidator(array $attributes) { $rules = array_only($this->getRules(), array_keys($attributes)); $validator = $this->validator->make($attributes, $rules, $this->getMessages()); $this->events->dispatch( new Validating($this, $validator) ); ...
php
{ "resource": "" }
q13693
Index.getApiDocument
train
private function getApiDocument(User $actor, array $params) { return json_decode($this->api->send(ListDiscussionsController::class, $actor, $params)->getBody()); }
php
{ "resource": "" }
q13694
ApiServiceProvider.registerNotificationSerializers
train
protected function registerNotificationSerializers() { $blueprints = []; $serializers = [ 'discussionRenamed' => BasicDiscussionSerializer::class ]; $this->app->make('events')->fire( new ConfigureNotificationTypes($blueprints, $serializers) ); ...
php
{ "resource": "" }
q13695
ApiServiceProvider.populateRoutes
train
protected function populateRoutes(RouteCollection $routes) { $factory = $this->app->make(RouteHandlerFactory::class); $callback = include __DIR__.'/routes.php'; $callback($routes, $factory); $this->app->make('events')->fire( new ConfigureApiRoutes($routes, $factory) ...
php
{ "resource": "" }
q13696
User.rename
train
public function rename($username) { if ($username !== $this->username) { $oldUsername = $this->username; $this->username = $username; $this->raise(new Renamed($this, $oldUsername)); } return $this; }
php
{ "resource": "" }
q13697
User.changeEmail
train
public function changeEmail($email) { if ($email !== $this->email) { $this->email = $email; $this->raise(new EmailChanged($this)); } return $this; }
php
{ "resource": "" }
q13698
User.requestEmailChange
train
public function requestEmailChange($email) { if ($email !== $this->email) { $this->raise(new EmailChangeRequested($this, $email)); } return $this; }
php
{ "resource": "" }
q13699
User.changeAvatarPath
train
public function changeAvatarPath($path) { $this->avatar_url = $path; $this->raise(new AvatarChanged($this)); return $this; }
php
{ "resource": "" }