_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q238500 | TridentMemoryUsageExtension.convertToBytes | train | private function convertToBytes($memoryLimit)
{
if ('-1' === $memoryLimit) {
return -1;
}
$memoryLimit = strtolower($memoryLimit);
$max = strtolower(ltrim($memoryLimit, '+'));
if (0 === strpos($max, '0x')) {
$max = intval($max, 16);
} elseif (... | php | {
"resource": ""
} |
q238501 | Laracasa.getAlbum | train | function getAlbum() {
$photos = new Zend_Gdata_Photos($this->client);
$query = new Zend_Gdata_Photos_AlbumQuery();
$query->setUser($this->user);
$query->setAlbumId($this->album);
$albumFeed = $photos->getAlbumFeed($query);
return $albumFeed;
} | php | {
"resource": ""
} |
q238502 | Laracasa.getPhotoById | train | function getPhotoById($photoId) {
$photos = new Zend_Gdata_Photos($this->client);
$query = new Zend_Gdata_Photos_PhotoQuery();
$query->setUser($this->user);
$query->setAlbumId($this->album);
$query->setPhotoId($photoId);
$query = $query->getQueryUrl() . "?kind=comment,tag... | php | {
"resource": ""
} |
q238503 | Laracasa.addPhoto | train | function addPhoto($photo) {
if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) {
$o = array('state' => false);
} else {
$photos = new Zend_Gdata_Photos($this->client);
$fd = $photos->newMediaFileSource($photo["tmp... | php | {
"resource": ""
} |
q238504 | Laracasa.deletePhoto | train | function deletePhoto($photoId) {
$photos = new Zend_Gdata_Photos($this->client);
$photoQuery = new Zend_Gdata_Photos_PhotoQuery;
$photoQuery->setUser($this->user);
$photoQuery->setAlbumId($this->album);
$photoQuery->setPhotoId($photoId);
$photoQuery->setType('ent... | php | {
"resource": ""
} |
q238505 | YamlConfigFactory.override | train | public function override($configFile, $strict = false) {
parent::override($this->_parse($configFile, $strict));
} | php | {
"resource": ""
} |
q238506 | PhpMailerDriver.from | train | public function from($mail, $name = null)
{
$this->mailer->setFrom($mail, $name);
return $this;
} | php | {
"resource": ""
} |
q238507 | PhpMailerDriver.body | train | public function body($body = '', $contentType = 'text/html')
{
$this->mailer->Body = $body;
$this->mailer->ContentType = $contentType;
return $this;
} | php | {
"resource": ""
} |
q238508 | Http.issue | train | public function issue()
{
// If there is no next URL, just output the headers as expected.
foreach ($this->headers as $key => $value) {
header("{$key}: {$value}", true);
}
// Output content type.
if ($this->contentType) {
header("content-type: {$this-... | php | {
"resource": ""
} |
q238509 | Http.setStatus | train | public function setStatus($status)
{
$result = \Eix\Services\Net\Http::isStatusCodeValid($status);
if ($result) {
$this->status = $status;
}
return $result;
} | php | {
"resource": ""
} |
q238510 | Http.addStatusMessage | train | protected function addStatusMessage($type, $messages)
{
if (!is_array($messages)) {
$messages = array($messages);
}
$this->addData('status', array($type => $messages));
} | php | {
"resource": ""
} |
q238511 | Customer.findByPasswordResetToken | train | public static function findByPasswordResetToken($token)
{
$expire = Yii::$app->params['user.passwordResetTokenExpire'];
$parts = explode('_', $token);
$timestamp = (int) end($parts);
if ($timestamp + $expire < time()) {
// token expired
return null;
}
... | php | {
"resource": ""
} |
q238512 | CreateConfigsTables.categories | train | private function categories()
{
$package = Package::where('name', 'Core')->first();
$core = ConfigCategory::create([
'key' => 'core',
'package_id' => $package->id
]);
ConfigCategory::create([
'key' => 'core_mail',
'parent_id' => $core->... | php | {
"resource": ""
} |
q238513 | RouterFactory.createService | train | public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object
{
$config = $serviceLocator->getConfig();
$config = $config[RouterInterface::class] ?? [];
$router = new Router();
foreach ($config['routes'] ?? [] as $name => $config) {... | php | {
"resource": ""
} |
q238514 | RouterFactory.createGroup | train | protected function createGroup(
ServiceLocatorInterface $serviceLocator,
RouteInterface $route,
array $children,
bool $abstract = null
): RouteInterface {
/** @var GroupRoute $group */
$group = $serviceLocator->getService(GroupRoute::class, [
'route' => $r... | php | {
"resource": ""
} |
q238515 | Options.addGroup | train | public function addGroup($str_alias, $str_name = null)
{
if (!isset(self::$arr_group[$str_alias])) {
$grp = new \stdClass();
$grp->name = (strlen($str_name)) ? $str_name : null;
$grp->args = array();
self::$arr_group[$str_alias] = $grp;
}
ret... | php | {
"resource": ""
} |
q238516 | Options.add | train | public static function add(OptionItem $opt, $str_alias = null)
{
// tester ici si version ou aide : à ne pas mettre
if(
!in_array($opt->getShort(true), self::$arr_prohibited, true)
&&
!in_array($opt->getLong(true), self::$arr_prohibited, true)
)
{
... | php | {
"resource": ""
} |
q238517 | Options.newSwitch | train | public function newSwitch($name, $group = null)
{
$arg = OptionItem::createSwitch($name);
if ($this->obj_color->opt) {
$arg->color($this->obj_color->opt);
}
if ($this->obj_color->bold) {
$arg->bold();
}
self::add($arg, $group);
retu... | php | {
"resource": ""
} |
q238518 | Options.newValue | train | public function newValue($name, $group = null)
{
$arg = OptionItem::createValue($name);
if ($this->obj_color->opt) {
$arg->color($this->obj_color->opt);
}
if ($this->obj_color->bold) {
$arg->bold();
}
self::add($arg, $group);
return... | php | {
"resource": ""
} |
q238519 | Options.getDescription | train | public function getDescription()
{
if (is_string($this->str_description)) {
$description = new S($this->str_description);
return $description->wrap(OptionItem::getWidth());
} else {
return null;
}
} | php | {
"resource": ""
} |
q238520 | Options.displayHelp | train | public function displayHelp()
{
printf("%s\n", $this->getUsage());
printf("%s\n", $this->getDescription());
// Les options non incluses dans un groupe
if (count(self::$arr_opt)) {
foreach (self::$arr_opt as $arg) {
printf("%s\n", rtrim($arg));
... | php | {
"resource": ""
} |
q238521 | Stream.refresh | train | protected function refresh() : bool
{
// Without a resource to grab the metadata for, let invokers know there's no data
// to work with presently.
if (!$this->resource) {
return false;
}
// Prepare the status mask if necessary. Might as well give it a value to be... | php | {
"resource": ""
} |
q238522 | JSONHTTPResponse.render | train | public static function render($textCode, $other=null, $domain='global', $description=null) {
$response = new static();
$response->collectFrom($textCode, $other, $domain, $description);
return $response;
} | php | {
"resource": ""
} |
q238523 | IdentityGenerator.generate | train | public function generate($suggestion = null)
{
if (null !== $suggestion) {
$this->dataStore->storeIdentity($suggestion, $this->mob);
return $suggestion;
}
$exceptions = array();
for ($i = 0; $i <= $this->maxRetries; $i++) {
$generatedIdentity = n... | php | {
"resource": ""
} |
q238524 | Transaction.rollBack | train | public function rollBack() {
return $this->inTransaction ? ($this->in = $this->doRollBack($this->name)) : false;
} | php | {
"resource": ""
} |
q238525 | Insert.do | train | public function do(String $app, $key, String $data = NULL) : Bool
{
$datas = [];
$createFile = $this->_langFile($app);
if( ! is_file($createFile) )
{
file_put_contents($createFile, json_encode([]));
}
$datas = json_decode(file_get_contents($createFile),... | php | {
"resource": ""
} |
q238526 | Escape.doNotEscape | train | public function doNotEscape($doNotEscape = []): void
{
$this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape));
} | php | {
"resource": ""
} |
q238527 | Escape.escape | train | public function escape($value = null, array $doNotEscape = [])
{
$this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape));
if (\is_null($value)) {
return 'NULL';
}
if (\is_int($value) || \is_float($value)) {
return $value;
}
... | php | {
"resource": ""
} |
q238528 | DynamicZone.getTriggerHtmlId | train | public function getTriggerHtmlId()
{
$form = $this->getParentOfType('\\Zepi\\Web\\UserInterface\\Form\Form');
if (is_object($form)) {
$part = $form->searchPartByKeyAndType($this->triggerKey);
return $part->getHtmlId();
}
return '';
} | php | {
"resource": ""
} |
q238529 | Query.AndWhere | train | public function AndWhere($condition, array $values) {
$this->andWheres[] = $condition;
$this->addBindValues($values);
return $this;
} | php | {
"resource": ""
} |
q238530 | Query.Where | train | public function Where($condition, $values) {
$this->setWhere($condition);
$this->addBindValues($values);
return $this;
} | php | {
"resource": ""
} |
q238531 | Query.execute | train | public function execute() {
$statement = $this->buildStatement();
$result = $this->getDataSource()->query($statement, $this->getBindValues());
if ($result) {
$collection = new Collection($this->getMapper()->getClass(), $result, $this->getMapper());
} else {
$coll... | php | {
"resource": ""
} |
q238532 | DbCommand.queryInternal | train | protected function queryInternal($method, $fetchMode = null)
{
if ($method !== '') {
$rawSql = $this->getRawSql();
$requestLocalCacheKey = implode('', [
__CLASS__,
$method,
$fetchMode,
$this->db->dsn,
$th... | php | {
"resource": ""
} |
q238533 | Local.isAbsolute | train | public function isAbsolute($path)
{
$firstChar = substr($path, 0, 1);
if ('/' === $firstChar || '\\' === $firstChar) {
return true;
}
$isLetter = (
($firstChar >= 'A' && $firstChar <= 'Z') ||
($firstChar >= 'a' && $firstChar <= 'z')
);
... | php | {
"resource": ""
} |
q238534 | Accessor.hasProperty | train | public function hasProperty($name)
{
static $vars = null;
if (! $vars) {
$vars = get_object_vars($this);
}
return array_key_exists($name, $vars);
} | php | {
"resource": ""
} |
q238535 | Debug.dumpTree | train | private static function dumpTree(NodeInterface $node, $verbose, $indent = 0)
{
list($attributes, $nodes) = self::extract($node);
$dump = get_class($node);
if ($attributes) {
$dump .= ' (';
$dump .= implode(', ', array_map(
function ($key, $value) us... | php | {
"resource": ""
} |
q238536 | Debug.extract | train | private static function extract(NodeInterface $node)
{
$attributes = [];
$nodes = [];
foreach (self::extractProperties($node) as $name => $value) {
if (is_array($value)) {
foreach ($value as $item) {
if ($item instanceof NodeInterface) {
... | php | {
"resource": ""
} |
q238537 | Debug.extractProperties | train | private static function extractProperties(NodeInterface $node)
{
$class = new \ReflectionClass($node);
foreach ($class->getProperties() as $property) {
if (!$property->isPublic()) {
$property->setAccessible(true);
}
$name = $property->getName();
... | php | {
"resource": ""
} |
q238538 | Debug.stringify | train | private static function stringify($value)
{
if (is_string($value)) {
return sprintf('"%s"', preg_replace('/\n/', '\n', $value));
}
if (is_bool($value)) {
return $value ? 'true' : 'false';
}
if (is_null($value)) {
return 'null';
}
... | php | {
"resource": ""
} |
q238539 | AddMany.removeAbandonedPosts | train | public static function removeAbandonedPosts() {
$sub_posts = \SubPost::getWhere(array('post_parent' => 0));
foreach($sub_posts as $sp) {
wp_delete_post($sp->ID, true);
}
} | php | {
"resource": ""
} |
q238540 | AuthRagnarok.retrieve | train | public function retrieve($name)
{
$this->userRagnarok = Session::get($this->getName());
if (property_exists($this->userRagnarok, $name)) {
return $this->userRagnarok->$name;
}
return null;
} | php | {
"resource": ""
} |
q238541 | AuthRagnarok.make | train | public function make($user)
{
$RagnarokUser = new SecUser();
$this->userRagnarok = $RagnarokUser->populate($user);
Session::put($this->getName(), $this->userRagnarok);
return $this->userRagnarok;
} | php | {
"resource": ""
} |
q238542 | AuthRagnarok.instance | train | public function instance($data)
{
$RagnarokUser = new SecUser();
$this->userRagnarok = $RagnarokUser->populate($data);
return $this->userRagnarok;
} | php | {
"resource": ""
} |
q238543 | InputRequest.process | train | public function process() {
$route = $this->findFirstMatchingRoute();
if( !$route ) {
// Not found, look for an alternative (with /)
$route = $this->findFirstMatchingRoute(true);
if( $route ) {
// Alternative found, try to redirect to this one
$r = $this->redirect($route);
if( $r ) {
// Re... | php | {
"resource": ""
} |
q238544 | InputRequest.processRoute | train | public function processRoute($route) {
if( !$route ) {
throw new NotFoundException('No route matches the current request '.$this);
}
$this->setRoute($route);
return $this->route->run($this);
} | php | {
"resource": ""
} |
q238545 | Image.setWidth | train | public function setWidth( $width )
{
$this->width = empty( $width ) ? null : (int) $width;
return $this;
} | php | {
"resource": ""
} |
q238546 | Image.setHeight | train | public function setHeight( $height )
{
$this->height = empty( $height ) ? null : (int) $height;
return $this;
} | php | {
"resource": ""
} |
q238547 | Encrypt.processValue | train | protected function processValue(callable $func, CacheItem $item)
{
$item->setStrVal($func($item->getStrVal()));
return true;
} | php | {
"resource": ""
} |
q238548 | LibXL.getExcelBook | train | public function getExcelBook($file_format = self::FILE_FORMAT_XLSX, $locale = 'UTF-8')
{
//@codeCoverageIgnoreStart
if (!extension_loaded('excel')) {
throw new Exception\RuntimeException(__METHOD__ . ' LibXL requires excel extension (https://github.com/iliaal/php_excel) and http://libxl.... | php | {
"resource": ""
} |
q238549 | LibXL.isSupportedFormat | train | public static function isSupportedFormat($format)
{
if (!is_string($format)) {
throw new Exception\InvalidArgumentException(__METHOD__ . " file_format must be a string");
}
return in_array((string) $format, self::$supportedFormats);
} | php | {
"resource": ""
} |
q238550 | LibXL.setDefaultLicense | train | public static function setDefaultLicense(array $license)
{
if (!array_key_exists('name', $license) || !array_key_exists('key', $license)) {
throw new Exception\InvalidArgumentException(__METHOD__ . " In order to set a default libxl license you must provide an associative array with 'name' and 'k... | php | {
"resource": ""
} |
q238551 | CloudFilesHelper.getContainer | train | protected function getContainer($name)
{
if (!isset($this->containers[$name])) {
$this->createContainer($name);
}
return $this->containers[$name];
} | php | {
"resource": ""
} |
q238552 | CloudFilesHelper.createContainer | train | protected function createContainer($name)
{
$this->containers[$name] = new Container($this->getView(), $this->service, $name);
} | php | {
"resource": ""
} |
q238553 | Transaction.rollbackWithoutThrow | train | public function rollbackWithoutThrow()
{
if (! $this->isValid()) return;
foreach ($this->getConnections() as $connection) {
$connection->rollback();
}
$this->_depth = 0;
} | php | {
"resource": ""
} |
q238554 | EloquentPresenter.createdAtDatetime | train | public function createdAtDatetime()
{
return $this->entity->created_at->setTimezone($this->config->get('config.timezone'))
->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format'));
} | php | {
"resource": ""
} |
q238555 | EloquentPresenter.updatedAtDate | train | public function updatedAtDate()
{
return $this->entity->updated_at->setTimezone($this->config->get('config.timezone'))
->format($this->config->get('config.date_format'));
} | php | {
"resource": ""
} |
q238556 | EloquentPresenter.updatedAtDatetime | train | public function updatedAtDatetime()
{
return $this->entity->updated_at->setTimezone($this->config->get('config.timezone'))
->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format'));
} | php | {
"resource": ""
} |
q238557 | Response.where | train | public function where($field, $section = 'Reference') {
// default to reference
if($section === null) {
$section = 'Reference';
}
// array_values reindexes the array here, otherwise we have gaps from non-matching array keys
return new FilterableList(array_values(array_filter($this->sections, function(Secti... | php | {
"resource": ""
} |
q238558 | ArrayTools.flatten | train | public static function flatten(array $arr)
{
$flat = [];
foreach ($arr as $v) {
if (is_array($v)) {
$flat = array_merge($flat, self::flatten($v));
} else {
$flat[] = $v;
}
}
return $flat;
} | php | {
"resource": ""
} |
q238559 | ArrayTools.isIndexed | train | public static function isIndexed(array $array)
{
$i = 0;
foreach (array_keys($array) as $k) {
if ($k !== $i) {
return false;
}
$i++;
}
return true;
} | php | {
"resource": ""
} |
q238560 | ServiceAbstract.addRole | train | public function addRole($role, $parents = null)
{
$this->getAcl()->addRole($role, $parents);
return $this;
} | php | {
"resource": ""
} |
q238561 | MetadataFactory.getClassMetadata | train | public function getClassMetadata($class)
{
$class = ltrim($class, '\\');
$metadataIndex = $this->getCacheId($class);
if (isset($this->loadedMetadata[$metadataIndex])) {
return $this->loadedMetadata[$metadataIndex];
}
if (isset($this->cache)) {
if (fa... | php | {
"resource": ""
} |
q238562 | QuestionHelper.setInputStream | train | public function setInputStream($stream)
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED);
if (!is_resource($stream)) {
throw new InvalidAr... | php | {
"resource": ""
} |
q238563 | QuestionHelper.getInputStream | train | public function getInputStream()
{
if (0 === func_num_args() || func_get_arg(0)) {
@trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED);
}
... | php | {
"resource": ""
} |
q238564 | QuestionHelper.getShell | train | private function getShell()
{
if (null !== self::$shell) {
return self::$shell;
}
self::$shell = false;
if (file_exists('/usr/bin/env')) {
// handle other OSs with bash/zsh/ksh/csh if available to hide the answer
$test = "/usr/bin/env %s -c 'echo... | php | {
"resource": ""
} |
q238565 | OutputSubscriber.onMessage | train | public function onMessage(MessageEvent $e)
{
$formatter = $this->getFormatter();
$adapterKey = $e->getAdapter()->getKey();
$level = $e->getLevel();
$message = $e->getMessage();
$match = '/\r\n?/';
//check if the message has weird formatting before trying to format i... | php | {
"resource": ""
} |
q238566 | OutputSubscriber.onTranscodeStart | train | public function onTranscodeStart(TranscodeEvent $e)
{
$inpath = $e->getInputPath();
$presetKey = $e->getPreset();
$formatter = $this->getFormatter();
$msg = sprintf(
"Starting transcode of file %s with preset %s ...",
$formatter->formatBlock($inpath, 'info'),... | php | {
"resource": ""
} |
q238567 | OutputSubscriber.onTranscodeComplete | train | public function onTranscodeComplete(TranscodeEvent $e)
{
$outpath = $e->getOutputPath();
$totalTime = microtime(true) - $this->startTime;
$formatter = $this->getFormatter();
$msg = sprintf(
"Transcode completed in %s seconds.",
$formatter->formatBlock(round($... | php | {
"resource": ""
} |
q238568 | OutputSubscriber.onTranscodeFailure | train | public function onTranscodeFailure(TranscodeEvent $e)
{
$inpath = $e->getInputPath();
$errorMsg = $e->getException()->getMessage();
$formatter = $this->getFormatter();
$msg = sprintf(
"Transcode of %s failed! Message: %s",
$formatter->formatBlock($inpath, 'i... | php | {
"resource": ""
} |
q238569 | Migration.newMigration | train | public function newMigration($name)
{
$time = time();
$date = date("n/j/Y");
$fileName = "{$time}_migration.php";
if ($name) $fileName = "{$time}_{$name}.php";
$file = $this->storagePath . "/" . $fileName;
$class = 'Migration_' . ((int)$time);
$contents = ar... | php | {
"resource": ""
} |
q238570 | Migration.createTable | train | public function createTable($name, $data)
{
$q = "CREATE TABLE {$name} (";
foreach ($data as $key => $v) {
$q .= $key;
if (isset($v['type'])) {
$q .= " {$v['type']}";
if (isset($v['length'])) {
$q .= "({$v['length']})";
... | php | {
"resource": ""
} |
q238571 | EmailConfig.createEventConfig | train | public static function createEventConfig(Event $event)
{
if ($event->sender->handler_class != Item::className()
|| $event->sender->handler_method != Item::HANDLER_METHOD
) {
return false;
}
$model = new self([
'title' => 'new config',
'... | php | {
"resource": ""
} |
q238572 | DataTrait.setData | train | public function setData(array $data, $replaceTemplateVariables = true) : self
{
$this->assertDataIsWritable();
if ($replaceTemplateVariables) {
$data = $this->replaceTemplateVariables($data);
}
$this->_data = $data;
return $this;
} | php | {
"resource": ""
} |
q238573 | DataTrait.replaceTemplateVariables | train | public function replaceTemplateVariables($data)
{
$this->assertDataIsWritable();
if ($templateVariables = $this->getOption('templateVariables', [])) {
$templateVariableKeys = array_keys($templateVariables);
if (is_string($data)) {
$data = str_replace($templa... | php | {
"resource": ""
} |
q238574 | DataTrait.has | train | public function has(string $index, array $options = []) : bool
{
$separator = isset($options['separator']) ?
$options['separator'] :
$this->getOption('separator', '.');
$value = $this->getData();
$keys = explode($separator, $index);
foreach ($keys as $key) {
... | php | {
"resource": ""
} |
q238575 | LoadMenus.load | train | public function load()
{
// Make the $menu variable available to all files
$menu = app('menu');
// Include menu files
$files = $this->getFiles();
/** @var \SplFileInfo $file */
foreach ($files as $file) {
require_once $file->getPath() . '/' . $file->getF... | php | {
"resource": ""
} |
q238576 | LoadMenus.getPath | train | protected function getPath(): string
{
$directory = config('menus.directory');
if (! $directory) {
throw new DirectoryNotFound('Directory with menu files does not exist.');
}
$path = $this->file->exists(base_path($directory)) ? base_path($directory) : __DIR__ . '/../res... | php | {
"resource": ""
} |
q238577 | LoadMenus.getFiles | train | protected function getFiles(): array
{
$path = $this->getPath();
$files = $this->file->allFiles($path);
if (! $files) {
throw new MenuFilesNotFound("Menu files have not been found in [{$path}].");
}
return $files;
} | php | {
"resource": ""
} |
q238578 | iauTf2d.Tf2d | train | public static function Tf2d($s, $ihour, $imin, $sec, &$days) {
/* Compute the interval. */
$days = ( $s == '-' ? -1.0 : 1.0 ) *
( 60.0 * ( 60.0 * ( (double)abs($ihour) ) +
( (double)abs($imin) ) ) +
abs($sec) ) / DAYSEC;
/* Validate arguments and return status. */
if... | php | {
"resource": ""
} |
q238579 | StripeGateway.charge | train | public function charge(InvoicePayment $payment)
{
// Make a charge through Stripe
try {
$charge = Charge::create([
// Multiply by 100 as Stripe charges in pence.
'amount' => $payment->amount * 100,
'currency' => 'gbp',
'desc... | php | {
"resource": ""
} |
q238580 | IPv4.parse | train | protected function parse(): void
{
switch ($this->notation) {
case self::NOTATION_DOT_DECIMAL:
$this->fromDotDecimal($this->value);
break;
case self::NOTATION_BINARY:
$this->fromBinary($this->value);
break;
... | php | {
"resource": ""
} |
q238581 | IPv4.isValid | train | public function isValid(): bool
{
$segments = explode('.', $this->value, self::NUM_SEGMENTS);
if (count($segments) !== self::NUM_SEGMENTS) {
return false;
}
for ($i = 0; $i < self::NUM_SEGMENTS; $i++) {
$value = (int) $segments[$i];
if ($value <... | php | {
"resource": ""
} |
q238582 | Problem.toArray | train | public function toArray()
{
return [
'severity' => $this->severity,
'msg' => $this->msg,
'hint' => $this->hint,
'link' => !empty($this->link) ? $this->link : null,
'iconCls' => $this->iconClass,
];
} | php | {
"resource": ""
} |
q238583 | ByPass.byPassCache | train | public function byPassCache(EventInterface $event)/*# : bool */
{
/* @var CachePool $pool */
$pool = $event->getTarget();
if ($this->trigger === '' || isset($_REQUEST[$this->trigger])) {
return $pool->setError(
Message::get(Message::CACHE_EXT_BYPASS),
... | php | {
"resource": ""
} |
q238584 | FastPriorityQueue.insert | train | public function insert($value, $priority)
{
if (! is_int($priority)) {
throw new Exception\InvalidArgumentException('The priority must be an integer');
}
$this->values[$priority][] = $value;
if (! isset($this->priorities[$priority])) {
$this->priorities[$prior... | php | {
"resource": ""
} |
q238585 | FastPriorityQueue.extract | train | public function extract()
{
if (! $this->valid()) {
return false;
}
$value = $this->current();
$this->nextAndRemove();
return $value;
} | php | {
"resource": ""
} |
q238586 | FastPriorityQueue.current | train | public function current()
{
switch ($this->extractFlag) {
case self::EXTR_DATA:
return current($this->values[$this->maxPriority]);
case self::EXTR_PRIORITY:
return $this->maxPriority;
case self::EXTR_BOTH:
return [
... | php | {
"resource": ""
} |
q238587 | FastPriorityQueue.nextAndRemove | train | protected function nextAndRemove()
{
if (false === next($this->values[$this->maxPriority])) {
unset($this->priorities[$this->maxPriority]);
unset($this->values[$this->maxPriority]);
$this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities);
$t... | php | {
"resource": ""
} |
q238588 | FastPriorityQueue.next | train | public function next()
{
if (false === next($this->values[$this->maxPriority])) {
unset($this->subPriorities[$this->maxPriority]);
reset($this->values[$this->maxPriority]);
$this->maxPriority = empty($this->subPriorities) ? 0 : max($this->subPriorities);
$this... | php | {
"resource": ""
} |
q238589 | FastPriorityQueue.rewind | train | public function rewind()
{
$this->subPriorities = $this->priorities;
$this->maxPriority = empty($this->priorities) ? 0 : max($this->priorities);
$this->index = 0;
$this->subIndex = 0;
} | php | {
"resource": ""
} |
q238590 | FastPriorityQueue.setExtractFlags | train | public function setExtractFlags($flag)
{
switch ($flag) {
case self::EXTR_DATA:
case self::EXTR_PRIORITY:
case self::EXTR_BOTH:
$this->extractFlag = $flag;
break;
default:
throw new Exception\InvalidArgumentExcep... | php | {
"resource": ""
} |
q238591 | Request.getIPAddress | train | public static function getIPAddress()
{
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
///to check ip is pass from proxy
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (is... | php | {
"resource": ""
} |
q238592 | Armourer.getOffensivenessOfWeaponlike | train | public function getOffensivenessOfWeaponlike(WeaponlikeCode $weaponlikeCode): int
{
return $this->tables->getWeaponlikeTableByWeaponlikeCode($weaponlikeCode)->getOffensivenessOf($weaponlikeCode);
} | php | {
"resource": ""
} |
q238593 | Armourer.canHoldItByTwoHands | train | public function canHoldItByTwoHands(WeaponlikeCode $weaponToHoldByTwoHands): bool
{
return
// shooting weapons are two-handed (except mini-crossbow), projectiles are not
$this->isTwoHandedOnly($weaponToHoldByTwoHands) // the weapon is explicitly two-handed
// or it is mel... | php | {
"resource": ""
} |
q238594 | Armourer.getMissingStrengthForArmament | train | public function getMissingStrengthForArmament(
ArmamentCode $armamentCode,
Strength $currentStrength,
Size $bodySize
): int
{
$requiredStrength = $this->tables->getArmamentsTableByArmamentCode($armamentCode)->getRequiredStrengthOf($armamentCode);
if ($requiredStrength ===... | php | {
"resource": ""
} |
q238595 | Armourer.getAttackNumberModifierByDistance | train | public function getAttackNumberModifierByDistance(
Distance $targetDistance,
EncounterRange $currentEncounterRange,
MaximalRange $currentMaximalRange
): int
{
if ($targetDistance->getBonus()->getValue() > $currentMaximalRange->getValue()) { // comparing distance bonuses in fact
... | php | {
"resource": ""
} |
q238596 | Armourer.getLoadingInRoundsByStrengthWithRangedWeapon | train | public function getLoadingInRoundsByStrengthWithRangedWeapon(
RangedWeaponCode $rangedWeaponCode,
Strength $currentStrength
): int
{
return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRounds(
$this->getMissingStrengthForArmament($rangedWeaponCode, $cur... | php | {
"resource": ""
} |
q238597 | Armourer.getLoadingInRoundsMalusByStrengthWithRangedWeapon | train | public function getLoadingInRoundsMalusByStrengthWithRangedWeapon(
RangedWeaponCode $rangedWeaponCode,
Strength $currentStrength
): int
{
return $this->tables->getRangedWeaponStrengthSanctionsTable()->getLoadingInRoundsSanction(
$this->getMissingStrengthForArmament($rangedWea... | php | {
"resource": ""
} |
q238598 | Armourer.getEncounterRangeWithWeaponlike | train | public function getEncounterRangeWithWeaponlike(
WeaponlikeCode $weaponlikeCode,
Strength $currentStrength,
Speed $currentSpeed
): EncounterRange
{
if (!($weaponlikeCode instanceof RangedWeaponCode)) {
/** note: melee weapon length in meters is half of weapon length, ... | php | {
"resource": ""
} |
q238599 | Armourer.getProtectiveArmamentRestrictionForSkillRank | train | public function getProtectiveArmamentRestrictionForSkillRank(
ProtectiveArmamentCode $protectiveArmamentCode,
PositiveInteger $protectiveArmamentSkillRank
): int
{
$restriction = $this->getRestrictionOfProtectiveArmament($protectiveArmamentCode)
+ $this->getProtectiveArmament... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.