_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q19000
Miner.mergeWhereInto
train
public function mergeWhereInto(Miner $Miner) { foreach ($this->where as $where) { // Handle open/close brackets differently than other criteria. if (array_key_exists('bracket', $where)) { if (strcmp($where['bracket'], self::BRACKET_OPEN) == 0) { $M...
php
{ "resource": "" }
q19001
Miner.openCriteria
train
private function openCriteria(array &$criteria, $connector = self::LOGICAL_AND) {
php
{ "resource": "" }
q19002
Miner.mergeGroupByInto
train
public function mergeGroupByInto(Miner $Miner) { foreach ($this->groupBy as
php
{ "resource": "" }
q19003
Miner.mergeHavingInto
train
public function mergeHavingInto(Miner $Miner) { foreach ($this->having as $having) { // Handle open/close brackets differently than other criteria. if (array_key_exists('bracket', $having)) { if (strcmp($having['bracket'], self::BRACKET_OPEN) == 0) { ...
php
{ "resource": "" }
q19004
Miner.mergeOrderByInto
train
public function mergeOrderByInto(Miner $Miner) { foreach ($this->orderBy as
php
{ "resource": "" }
q19005
Miner.orderBy
train
public function orderBy($column, $order = self::ORDER_BY_ASC) { $this->orderBy[] = array('column' => $column,
php
{ "resource": "" }
q19006
Miner.mergeLimitInto
train
public function mergeLimitInto(Miner $Miner) { if ($this->limit) {
php
{ "resource": "" }
q19007
Miner.mergeIntoColumns
train
public function mergeIntoColumns(Miner $Miner) { if ($this->intoColums) {
php
{ "resource": "" }
q19008
Miner.mergeIntoValues
train
public function mergeIntoValues(Miner $Miner) { if ($this->intoValues) {
php
{ "resource": "" }
q19009
Miner.mergeSetInto
train
public function mergeSetInto(Miner $Miner) { foreach ($this->set as $set)
php
{ "resource": "" }
q19010
Miner.mergeUpdateInto
train
public function mergeUpdateInto(Miner $Miner) { $this->mergeOptionsInto($Miner); if ($this->update) {
php
{ "resource": "" }
q19011
Miner.mergeDeleteInto
train
public function mergeDeleteInto(Miner $Miner) { $this->mergeOptionsInto($Miner); if ($this->isDeleteTableFrom()) { $Miner->delete(); } else {
php
{ "resource": "" }
q19012
Miner.delete
train
public function delete($table = false) { if ($table === false) { $this->delete = true; } else { // Reset the array in case the class variable was previously set to a // boolean value. if
php
{ "resource": "" }
q19013
SwooleIO.connect
train
public function connect() { $sock = new Swoole\Coroutine\Client(SWOOLE_SOCK_TCP); if (!$sock->connect($this->host, $this->port, $this->connection_timeout)) { throw new AMQPRuntimeException( sprintf( 'Error Connecting to server(%s): %s ', ...
php
{ "resource": "" }
q19014
Blade.render
train
public function render($view, $data = [], $mergeData = []) {
php
{ "resource": "" }
q19015
PeclUuidTimeGenerator.generate
train
public function generate($node = null, $clockSeq = null) {
php
{ "resource": "" }
q19016
DegradedUuidBuilder.build
train
public function build(CodecInterface $codec, array $fields) { return new
php
{ "resource": "" }
q19017
BinaryUtils.applyVersion
train
public static function applyVersion($timeHi, $version) { $timeHi = hexdec($timeHi) & 0x0fff; $timeHi &= ~(0xf000);
php
{ "resource": "" }
q19018
TimestampFirstCombCodec.encode
train
public function encode(UuidInterface $uuid) { $sixPieceComponents = array_values($uuid->getFieldsHex()); $this->swapTimestampAndRandomBits($sixPieceComponents); return vsprintf(
php
{ "resource": "" }
q19019
TimestampFirstCombCodec.encodeBinary
train
public function encodeBinary(UuidInterface $uuid) { $stringEncoding = $this->encode($uuid);
php
{ "resource": "" }
q19020
TimestampFirstCombCodec.decode
train
public function decode($encodedUuid) { $fivePieceComponents = $this->extractComponents($encodedUuid); $this->swapTimestampAndRandomBits($fivePieceComponents);
php
{ "resource": "" }
q19021
TimestampFirstCombCodec.swapTimestampAndRandomBits
train
protected function swapTimestampAndRandomBits(array &$components) { $last48Bits = $components[4]; if (count($components) == 6) { $last48Bits = $components[5]; $components[5] = $components[0] . $components[1]; } else {
php
{ "resource": "" }
q19022
DefaultTimeGenerator.generate
train
public function generate($node = null, $clockSeq = null) { $node = $this->getValidNode($node); if ($clockSeq === null) { // Not using "stable storage"; see RFC 4122, Section 4.2.1.1 $clockSeq = random_int(0, 0x3fff); } // Create a 60-bit time value as a coun...
php
{ "resource": "" }
q19023
UuidFactory.uuidFromNsAndName
train
protected function uuidFromNsAndName($ns, $name, $version, $hashFunction) { if (!($ns instanceof UuidInterface)) {
php
{ "resource": "" }
q19024
StringCodec.decode
train
public function decode($encodedUuid) { $components = $this->extractComponents($encodedUuid); $fields
php
{ "resource": "" }
q19025
StringCodec.decodeBytes
train
public function decodeBytes($bytes) { if (strlen($bytes) !== 16) { throw new InvalidArgumentException('$bytes string should contain 16 characters.'); }
php
{ "resource": "" }
q19026
StringCodec.getFields
train
protected function getFields(array $components) { return [ 'time_low' => str_pad($components[0], 8, '0', STR_PAD_LEFT), 'time_mid' => str_pad($components[1], 4, '0', STR_PAD_LEFT), 'time_hi_and_version' => str_pad($components[2], 4, '0', STR_PAD_LEFT), 'clock_...
php
{ "resource": "" }
q19027
GuidStringCodec.encode
train
public function encode(UuidInterface $uuid) { $components = array_values($uuid->getFieldsHex()); // Swap byte-order on the first three fields $this->swapFields($components);
php
{ "resource": "" }
q19028
GuidStringCodec.encodeBinary
train
public function encodeBinary(UuidInterface $uuid) { $components
php
{ "resource": "" }
q19029
GuidStringCodec.decode
train
public function decode($encodedUuid) { $components = $this->extractComponents($encodedUuid); $this->swapFields($components);
php
{ "resource": "" }
q19030
GuidStringCodec.swapFields
train
protected function swapFields(array &$components) { $hex = unpack('H*', pack('L', hexdec($components[0]))); $components[0] = $hex[1]; $hex = unpack('H*', pack('S', hexdec($components[1])));
php
{ "resource": "" }
q19031
FallbackNodeProvider.getNode
train
public function getNode() { foreach ($this->nodeProviders as $provider) {
php
{ "resource": "" }
q19032
OrderedTimeCodec.encodeBinary
train
public function encodeBinary(UuidInterface $uuid) { $fields = $uuid->getFieldsHex(); $optimized = [ $fields['time_hi_and_version'], $fields['time_mid'], $fields['time_low'],
php
{ "resource": "" }
q19033
OrderedTimeCodec.decodeBytes
train
public function decodeBytes($bytes) { if (strlen($bytes) !== 16) { throw new InvalidArgumentException('$bytes string should contain 16 characters.'); } $hex = unpack('H*', $bytes)[1]; // Rearrange the fields to their original order
php
{ "resource": "" }
q19034
DefaultUuidBuilder.build
train
public function build(CodecInterface $codec, array $fields) {
php
{ "resource": "" }
q19035
CombGenerator.generate
train
public function generate($length) { if ($length < self::TIMESTAMP_BYTES || $length < 0) { throw new \InvalidArgumentException('Length must be a positive integer.'); } $hash = ''; if (self::TIMESTAMP_BYTES > 0 && $length > self::TIMESTAMP_BYTES) { $hash = $th...
php
{ "resource": "" }
q19036
BigNumberConverter.toHex
train
public function toHex($integer) { if (!$integer instanceof BigNumber) { $integer = new BigNumber($integer);
php
{ "resource": "" }
q19037
Uuid.unserialize
train
public function unserialize($serialized) { /** @var \Ramsey\Uuid\Uuid $uuid */ $uuid = self::fromString($serialized); $this->codec = $uuid->codec;
php
{ "resource": "" }
q19038
SystemNodeProvider.getIfconfig
train
protected function getIfconfig() { if (strpos(strtolower(ini_get('disable_functions')), 'passthru') !== false) { return ''; } ob_start(); switch (strtoupper(substr(php_uname('a'), 0, 3))) { case 'WIN': passthru('ipconfig /all 2>&1'); ...
php
{ "resource": "" }
q19039
SystemNodeProvider.getSysfs
train
protected function getSysfs() { $mac = false; if (strtoupper(php_uname('s')) === 'LINUX') { $addressPaths = glob('/sys/class/net/*/address', GLOB_NOSORT); if (empty($addressPaths)) { return false; } array_walk($addressPaths, function...
php
{ "resource": "" }
q19040
FeatureSet.buildCodec
train
protected function buildCodec($useGuids = false) { if ($useGuids) { return new GuidStringCodec($this->builder);
php
{ "resource": "" }
q19041
FeatureSet.buildTimeGenerator
train
protected function buildTimeGenerator(TimeProviderInterface $timeProvider) { if ($this->enablePecl) { return new PeclUuidTimeGenerator();
php
{ "resource": "" }
q19042
FeatureSet.buildTimeConverter
train
protected function buildTimeConverter() { if ($this->is64BitSystem()) { return new PhpTimeConverter(); } elseif ($this->hasGmp()) {
php
{ "resource": "" }
q19043
FeatureSet.buildUuidBuilder
train
protected function buildUuidBuilder() { if ($this->is64BitSystem()) { return new DefaultUuidBuilder($this->numberConverter, $this->timeConverter); }
php
{ "resource": "" }
q19044
Validator.validate
train
public function validate($uuid) { $uuid = str_replace(['urn:', 'uuid:', '{', '}'], '', $uuid); if ($uuid === Uuid::NIL || preg_match('/' . self::VALID_PATTERN .
php
{ "resource": "" }
q19045
Miner.columnQuote
train
public function columnQuote($column) { if (empty($column)) { return null; } preg_match('/^(?:(?<table>\w+)\.)?(?<column>\w+)$/iu', $column, $match); if (isset($match['table'], $match['column'])) { $table = $this->tableQuote($match['table']); $match...
php
{ "resource": "" }
q19046
Miner.set
train
public function set($column, $value = null, $quote = null) { if (is_array($column)) { foreach ($column as $columnName => $columnValue) { $this->set($columnName, $columnValue, $quote); } } else {
php
{ "resource": "" }
q19047
Miner.criteria
train
private function criteria(array &$criteria, $column, $value, $operator = self::EQUALS, $connector = self::LOGICAL_AND, $quote = null) { $criteria[] = array( 'column' => $this->columnQuote($column), 'value' => $value,
php
{ "resource": "" }
q19048
Miner.orHaving
train
public function orHaving($column, $value, $operator = self::EQUALS, $quote = null)
php
{ "resource": "" }
q19049
Miner.getJoinString
train
public function getJoinString() { $statement = ""; foreach ($this->join as $i => $join) { $statement .= " " . $join['type'] . " " . $join['table']; if ($join['alias']) { $statement .= " AS " . $join['alias']; } ...
php
{ "resource": "" }
q19050
Miner.mergeInto
train
public function mergeInto(Miner $Miner, $overrideLimit = true) { if ($this->isSelect()) { $this->mergeSelectInto($Miner); $this->mergeFromInto($Miner); $this->mergeJoinInto($Miner); $this->mergeWhereInto($Miner); $this->mergeGroupByInto($Miner); ...
php
{ "resource": "" }
q19051
Generator.prepareDirectory
train
protected function prepareDirectory() { if (File::exists($this->docDir) && ! is_writable($this->docDir)) { throw new L5SwaggerException('Documentation storage directory is not writable'); } // delete all existing documentation if
php
{ "resource": "" }
q19052
Generator.defineConstants
train
protected function defineConstants() { if (! empty($this->constants)) { foreach ($this->constants as $key => $value) {
php
{ "resource": "" }
q19053
Generator.scanFilesForDocumentation
train
protected function scanFilesForDocumentation() { if ($this->isOpenApi()) { $this->swagger = \OpenApi\scan( $this->appDir, ['exclude' => $this->excludedDirs] ); } if (! $this->isOpenApi())
php
{ "resource": "" }
q19054
Generator.populateServers
train
protected function populateServers() { if (config('l5-swagger.paths.base') !== null) { if ($this->isOpenApi()) { $this->swagger->servers = [ new \OpenApi\Annotations\Server(['url' => config('l5-swagger.paths.base')]), ];
php
{ "resource": "" }
q19055
Generator.saveJson
train
protected function saveJson() { $this->swagger->saveAs($this->docsFile); $security = new SecurityDefinitions();
php
{ "resource": "" }
q19056
Generator.makeYamlCopy
train
protected function makeYamlCopy() { if ($this->yamlCopyRequired) { file_put_contents(
php
{ "resource": "" }
q19057
SecurityDefinitions.generateSwaggerApi
train
public function generateSwaggerApi(Collection $documentation, array $securityConfig) { $securityDefinitions = collect(); if ($documentation->has('securityDefinitions')) { $securityDefinitions = collect($documentation->get('securityDefinitions')); } foreach ($securityConf...
php
{ "resource": "" }
q19058
SecurityDefinitions.generateOpenApi
train
public function generateOpenApi(Collection $documentation, array $securityConfig) { $components = collect(); if ($documentation->has('components')) { $components = collect($documentation->get('components')); } $securitySchemes = collect(); if ($components->has('s...
php
{ "resource": "" }
q19059
Tracker.updateGeoIp
train
public function updateGeoIp() { $updater = new GeoIpUpdater(); $success = $updater->updateGeoIpFiles($this->config->get('geoip_database_path'));
php
{ "resource": "" }
q19060
Message.addMessage
train
public function addMessage($message) { collect((array) $message)->each(function ($item) { collect($item)->flatten()->each(function ($flattened) {
php
{ "resource": "" }
q19061
RefererParser.parse
train
public function parse($refererUrl, $pageUrl) { $this->setReferer($this->parser->pars
php
{ "resource": "" }
q19062
UpdateGeoIp.fire
train
public function fire() { $tracker = app('tracker'); $type = $tracker->updateGeoIp()
php
{ "resource": "" }
q19063
Base.display
train
public function display($result, $method = 'info') { if ($result) { if (is_array($result)) { $this->displayTable($result); } elseif (is_bool($result)) {
php
{ "resource": "" }
q19064
Base.displayTable
train
public function displayTable($table) { $headers = $this->makeHeaders($table[0]); $rows = []; foreach ($table as $row) { $rows[] = (array) $row; } $this->table =
php
{ "resource": "" }
q19065
ServiceProvider.registerTracker
train
protected function registerTracker() { $this->app->singleton('tracker', function ($app) { $app['tracker.loaded'] = true; return new Tracker( $app['tracker.config'], $app['tracker.repositories'], ...
php
{ "resource": "" }
q19066
ServiceProvider.registerGlobalViewComposers
train
protected function registerGlobalViewComposers() { $me = $this; $this->app->make('view')->composer('pragmarx/tracker::*', function ($view) use ($me) {
php
{ "resource": "" }
q19067
Minutes.calculateStartEnd
train
private function calculateStartEnd() { if ($this->minutes == 0) { $this->setToday(); } else {
php
{ "resource": "" }
q19068
SlugService.slug
train
public function slug(Model $model, bool $force = false): bool { $this->setModel($model); $attributes = []; foreach ($this->model->sluggable() as $attribute => $config) { if (is_numeric($attribute)) { $attribute = $config; $config = $this->getConf...
php
{ "resource": "" }
q19069
SlugService.buildSlug
train
public function buildSlug(string $attribute, array $config, bool $force = null) { $slug = $this->model->getAttribute($attribute); if ($force || $this->needsSlugging($attribute, $config)) { $source = $this->getSlugSource($config['source']); if ($source || is_numeric($source)...
php
{ "resource": "" }
q19070
SlugService.getSlugSource
train
protected function getSlugSource($from): string { if (is_null($from)) { return $this->model->__toString(); } $sourceStrings = array_map(function($key) { $value = data_get($this->model, $key); if (is_bool($value)) {
php
{ "resource": "" }
q19071
SlugService.generateSlug
train
protected function generateSlug(string $source, array $config, string $attribute): string { $separator = $config['separator']; $method = $config['method']; $maxLength = $config['maxLength']; $maxLengthKeepWords = $config['maxLengthKeepWords']; if ($method === null) { ...
php
{ "resource": "" }
q19072
SlugService.validateSlug
train
protected function validateSlug(string $slug, array $config, string $attribute): string { $separator = $config['separator']; $reserved = $config['reserved']; if ($reserved === null) { return $slug; } // check for reserved names if ($reserved instanceof \...
php
{ "resource": "" }
q19073
SlugService.makeSlugUnique
train
protected function makeSlugUnique(string $slug, array $config, string $attribute): string { if (!$config['unique']) { return $slug; } $separator = $config['separator']; // find all models where the slug is like the current one $list = $this->getExistingSlugs($sl...
php
{ "resource": "" }
q19074
SlugService.generateSuffix
train
protected function generateSuffix(string $slug, string $separator, Collection $list): string { $len = strlen($slug . $separator); // If the slug already exists, but belongs to // our model, return the current suffix. if ($list->search($slug) === $this->model->getKey()) { ...
php
{ "resource": "" }
q19075
SlugService.createSlug
train
public static function createSlug($model, string $attribute, string $fromString, array $config = null): string { if (is_string($model)) { $model = new $model; } /** @var static $instance */ $instance = (new static())->setModel($model); if ($config === null) { ...
php
{ "resource": "" }
q19076
Sluggable.scopeFindSimilarSlugs
train
public function scopeFindSimilarSlugs(Builder $query, string $attribute, array $config, string $slug): Builder { $separator = $config['separator']; return $query->where(function(Builder $q) use ($attribute, $slug, $separator) {
php
{ "resource": "" }
q19077
SluggableScopeHelpers.getSlugKeyName
train
public function getSlugKeyName(): string { if (property_exists($this, 'slugKeyName')) { return $this->slugKeyName; } $config = $this->sluggable(); $name = reset($config); $key = key($config);
php
{ "resource": "" }
q19078
SluggableScopeHelpers.scopeWhereSlug
train
public function scopeWhereSlug(Builder $scope, string $slug): Builder
php
{ "resource": "" }
q19079
Downloader.extract
train
protected function extract($file, $path) { // we must use cmdline tar, as PharData::extract() messes up symlinks $command = 'tar -xzf ' . ProcessExecutor::escape($file) .
php
{ "resource": "" }
q19080
Downloader.download
train
public function download(PackageInterface $package, $path, $output = true) { $temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8); $this->filesystem->ensureDirectoryExists($temporaryDir); // START: from FileDownloader::download() if (!$package->getDistUrl()) { ...
php
{ "resource": "" }
q19081
Swift_Plugins_DecoratorPlugin.setReplacements
train
public function setReplacements($replacements) { if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) {
php
{ "resource": "" }
q19082
Swift_Plugins_DecoratorPlugin.getReplacementsFor
train
public function getReplacementsFor($address) { if ($this->replacements instanceof Swift_Plugins_Decorator_Replacements) {
php
{ "resource": "" }
q19083
Swift_Plugins_DecoratorPlugin.restoreMessage
train
private function restoreMessage(Swift_Mime_SimpleMessage $message) { if ($this->lastMessage === $message) { if (isset($this->originalBody)) { $message->setBody($this->originalBody); $this->originalBody = null; } if (!empty($this->originalHe...
php
{ "resource": "" }
q19084
Swift_Signers_DKIMSigner.reset
train
public function reset() { $this->headerHash = null; $this->signedHeaders = []; $this->bodyHash = null; $this->bodyHashHandler = null; $this->bodyCanonIgnoreStart = 2;
php
{ "resource": "" }
q19085
Swift_Signers_DKIMSigner.setHashAlgorithm
train
public function setHashAlgorithm($hash) { switch ($hash) { case 'rsa-sha1': $this->hashAlgorithm = 'rsa-sha1'; break; case 'rsa-sha256': $this->hashAlgorithm = 'rsa-sha256'; if (!defined('OPENSSL_ALGO_SHA256')) { ...
php
{ "resource": "" }
q19086
Swift_Signers_DKIMSigner.setBodySignedLen
train
public function setBodySignedLen($len) { if (true === $len) { $this->showLen = true; $this->maxLen = PHP_INT_MAX; } elseif (false === $len) { $this->showLen = false; $this->maxLen = PHP_INT_MAX;
php
{ "resource": "" }
q19087
Swift_Signers_DKIMSigner.startBody
train
public function startBody() { // Init switch ($this->hashAlgorithm) { case 'rsa-sha256': $this->bodyHashHandler = hash_init('sha256'); break; case 'rsa-sha1':
php
{ "resource": "" }
q19088
Swift_Signers_DKIMSigner.setHeaders
train
public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) { $this->headerCanonData = ''; // Loop through Headers $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header if (!isset($this->ignoredHeaders[...
php
{ "resource": "" }
q19089
Swift_Mime_Headers_AbstractHeader.setLanguage
train
public function setLanguage($lang) { $this->clearCachedValueIf($this->lang
php
{ "resource": "" }
q19090
Swift_Mime_Headers_AbstractHeader.getEncodableWordTokens
train
protected function getEncodableWordTokens($string) { $tokens = []; $encodedToken = ''; // Split at all whitespace boundaries foreach (preg_split('~(?=[\t ])~', $string) as $token) { if ($this->tokenNeedsEncoding($token)) { $encodedToken .= $token; ...
php
{ "resource": "" }
q19091
Swift_Signers_DomainKeySigner.reset
train
public function reset() { $this->hashHandler = null; $this->bodyCanonIgnoreStart = 2; $this->bodyCanonEmptyCounter = 0;
php
{ "resource": "" }
q19092
Swift_Mime_Headers_MailboxHeader.setNameAddresses
train
public function setNameAddresses($mailboxes) { $this->mailboxes = $this->normalizeMailboxes((array) $mailboxes);
php
{ "resource": "" }
q19093
Swift_Mime_Headers_MailboxHeader.removeAddresses
train
public function removeAddresses($addresses) { $this->setCachedValue(null);
php
{ "resource": "" }
q19094
Swift_Mime_Headers_MailboxHeader.normalizeMailboxes
train
protected function normalizeMailboxes(array $mailboxes) { $actualMailboxes = []; foreach ($mailboxes as $key => $value) { if (is_string($key)) { //key is email addr $address = $key; $name = $value; } else { $add...
php
{ "resource": "" }
q19095
Swift_Mime_Headers_MailboxHeader.createDisplayNameString
train
protected function createDisplayNameString($displayName, $shorten = false) {
php
{ "resource": "" }
q19096
Swift_Mime_Headers_MailboxHeader.createNameAddressStrings
train
private function createNameAddressStrings(array $mailboxes) { $strings = []; foreach ($mailboxes as $email => $name) { $mailboxStr = $this->addressEncoder->encodeString($email); if (null !== $name) { $nameStr = $this->createDisplayNameString($name,
php
{ "resource": "" }
q19097
Swift_Events_SimpleEventDispatcher.bindEventListener
train
public function bindEventListener(Swift_Events_EventListener $listener) { foreach ($this->listeners as $l) { // Already loaded if ($l === $listener) {
php
{ "resource": "" }
q19098
Swift_Events_SimpleEventDispatcher.dispatchEvent
train
public function dispatchEvent(Swift_Events_EventObject $evt, $target) {
php
{ "resource": "" }
q19099
Swift_KeyCache_DiskKeyCache.getHandle
train
private function getHandle($nsKey, $itemKey, $position) { if (!isset($this->keys[$nsKey][$itemKey])) { $openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b'; $fp = fopen($this->path.'/'.$nsKey.'/'.$itemKey, $openMode); $this->keys[$nsKey][$itemKey] = $fp; } ...
php
{ "resource": "" }