_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q12700
BaseHandler.sendChatActionReply
train
public function sendChatActionReply(): SendChatAction { $m = $this->bot->sendChatAction(); $this->setReplyMarkup($m, false); return $m; }
php
{ "resource": "" }
q12701
TaskSubType.copyTemplateFilesToProject
train
protected function copyTemplateFilesToProject(array $filenames, $overwrite = false) { try { $filesystem = $this->taskFilesystemStack(); foreach ($filenames as $template_path => $target_path) { $target_file = ProjectX::projectRoot() . "/{$target_path}"; ...
php
{ "resource": "" }
q12702
ArrayUtils.arrayDropdown
train
public static function arrayDropdown(array $raw, $partition, $key, $value) { $output = array(); foreach (self::arrayPartition($raw, $partition) as $target => $data) { foreach ($data as $innerKey => $innerValue) { if (isset($innerValue[$key], $innerValue[$value])) { ...
php
{ "resource": "" }
q12703
ArrayUtils.arrayPartition
train
public static function arrayPartition(array $raw, $key, $keepKey = true) { $result = array(); foreach ($raw as $index => $collection) { // Make the the root partition exists if (!isset($collection[$key])) { throw new LogicException(sprintf( ...
php
{ "resource": "" }
q12704
ArrayUtils.arrayRecovery
train
public static function arrayRecovery(array $array, array $keys, $value) { foreach ($keys as $key) { if (!isset($array[$key])) { $array[$key] = $value; } } return $array; }
php
{ "resource": "" }
q12705
ArrayUtils.valuefy
train
public static function valuefy(array $data, $valueModue = true) { if ($valueModue === true) { $values = array_values($data); } else { $values = array_keys($data); } return array_combine($values, $values); }
php
{ "resource": "" }
q12706
ArrayUtils.sumColumnsWithAverages
train
public static function sumColumnsWithAverages(array $entities, array $averages = array(), $precision = 2) { // Count the sum of all columns $sum = self::sumColumns($entities); if (!empty($averages)) { $count = count($entities); // Make sure that the division by zero...
php
{ "resource": "" }
q12707
ArrayUtils.roundValues
train
public static function roundValues(array $data, $precision = 2) { return self::filterValuesRecursively($data, function($value) use ($precision) { $value = is_numeric($value) ? round($value, $precision) : $value; $value = empty($value) ? 0 : $value; return $value; ...
php
{ "resource": "" }
q12708
ArrayUtils.arrayColumns
train
public static function arrayColumns(array $data) { // Count the amount of values from the source input $count = count($data); if ($count === 0) { return false; } if ($count === 1) { return array_keys($data[0]); } if (isset($data[0]))...
php
{ "resource": "" }
q12709
ArrayUtils.sumColumns
train
public static function sumColumns(array $data) { $columns = self::arrayColumns($data); if ($columns !== false){ return self::columnSum($data, $columns); } else { return false; } }
php
{ "resource": "" }
q12710
ArrayUtils.columnSum
train
public static function columnSum(array $data, array $columns) { $result = array(); foreach ($columns as $column) { foreach ($data as $collection) { if (isset($collection[$column])) { if (isset($result[$column])) { $result[$colu...
php
{ "resource": "" }
q12711
ArrayUtils.filterValuesRecursively
train
public static function filterValuesRecursively(array $array, Closure $callback = null) { foreach ($array as $index => $value) { if (is_array($value)) { $array[$index] = call_user_func(__METHOD__, $value, $callback); } else { $array[$index] = call_user_...
php
{ "resource": "" }
q12712
ArrayUtils.filterArray
train
public static function filterArray(array $array, Closure $callback) { foreach ($array as $index => $collection) { $array[$index] = call_user_func($callback, $collection); } return $array; }
php
{ "resource": "" }
q12713
ArrayUtils.mergeWithout
train
public static function mergeWithout(array $first, array $second, array $keys) { $result = array_merge($first, $second); return self::arrayWithout($result, $keys); }
php
{ "resource": "" }
q12714
ArrayUtils.keysExist
train
public static function keysExist(array $collection, array $keys) { $collection = array_flip($collection); foreach ($keys as $key) { if (!in_array($key, $collection)) { return false; } } return true; }
php
{ "resource": "" }
q12715
ArrayUtils.arrayOnlyWith
train
public static function arrayOnlyWith(array $array, array $keys) { $result = array(); if (!self::isSequential($array)) { foreach ($array as $key => $value) { if (in_array($key, $keys)) { $result[$key] = $value; } } }...
php
{ "resource": "" }
q12716
ArrayUtils.arrayCombine
train
public static function arrayCombine(array $first, array $second, $replacement = null, $order = true) { // Fix for different length if (count($first) !== count($second)) { $input = array($first, $second); $count = array_map('count', $input); // Find the largest an...
php
{ "resource": "" }
q12717
ArrayUtils.arrayList
train
public static function arrayList(array $array, $key, $value) { $result = array(); foreach ($array as $row) { if (array_key_exists($key, $row) && array_key_exists($value, $row)) { // References $name =& $row[$key]; $text =& $row[$value]; ...
php
{ "resource": "" }
q12718
ArrayUtils.arrayWithout
train
public static function arrayWithout(array $array, array $keys) { // Shared filter function $filter = function(array $array, array $keys) { foreach ($keys as $key) { if (array_key_exists($key, $array)) { unset($array[$key]); } ...
php
{ "resource": "" }
q12719
ArrayUtils.search
train
public static function search(array $haystack, $needle) { foreach ($haystack as $key => $value) { if (is_array($value)) { $target = self::search($value, $needle); } else { $target = ''; } if ($needle === $value || ($target != ...
php
{ "resource": "" }
q12720
ArrayUtils.arrayUnique
train
public static function arrayUnique(array $array) { // Serialize each array's value foreach ($array as &$value) { $value = serialize($value); } // Now remove duplicate strings $array = array_unique($array); // Now restore to its previous state with remove...
php
{ "resource": "" }
q12721
DocumentSelector.orderBy
train
public function orderBy(string $field, int $direction = self::ASCENDING): DocumentSelector { return $this->sortBy($this->sortBy + [$field => $direction]); }
php
{ "resource": "" }
q12722
DocumentSelector.findOne
train
public function findOne(array $query = [], bool $normalizeDates = true) { if ($normalizeDates) { $query = $this->normalizeDates($query); } //Working with projection (required to properly sort results) $result = $this->collection->findOne( array_merge($this->q...
php
{ "resource": "" }
q12723
DocumentSelector.count
train
public function count(array $query = []): int { //Create options? return $this->collection->count( array_merge($this->query, $query), ['skip' => $this->offset, 'limit' => $this->limit] ); }
php
{ "resource": "" }
q12724
DocumentSelector.normalizeDates
train
protected function normalizeDates(array $query): array { array_walk_recursive($query, function (&$value) { if ($value instanceof \DateTime) { //MongoDate is always UTC, which is good :) $value = new UTCDateTime($value); } }); return $q...
php
{ "resource": "" }
q12725
DrupalCacheAdapter.cache_set
train
public function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) { return cache_set($cid, $data, $bin, $expire); }
php
{ "resource": "" }
q12726
DockerServiceBase.getService
train
public function getService() { if (!isset($this->service)) { $info = $this->getInfo(); $this->service = $this->service(); // Apply the overridden property values. foreach (static::PROPERTIES_OVERRIDE as $property) { if (!isset($info[$property]...
php
{ "resource": "" }
q12727
DockerServiceBase.getEnvironmentValue
train
public function getEnvironmentValue($name) { $name = strtolower($name); $service = $this->getService(); foreach ($service->getEnvironment() as $environment) { list($key, $value) = explode('=', $environment); if (strtolower($key) !== $name) { continue;...
php
{ "resource": "" }
q12728
DockerServiceBase.getHostPorts
train
public function getHostPorts() { $ports = []; $service = $this->getService(); foreach ($service->getPorts() as $port) { list($host,) = explode(':', $port); $ports[] = $host; } return $ports; }
php
{ "resource": "" }
q12729
DockerServiceBase.getPorts
train
protected function getPorts($host = null) { $ports = $this->ports(); array_walk($ports, function (&$port) use ($host) { $host = isset($host) ? $host : $port; $port = "{$host}:{$port}"; }); return $ports; }
php
{ "resource": "" }
q12730
DockerServiceBase.getServiceNames
train
protected function getServiceNames() { $names = []; foreach ($this->getServices() as $name => $info) { if (!isset($info['type'])) { continue; } $names[$name] = $info['type']; } return $names; }
php
{ "resource": "" }
q12731
DockerServiceBase.alterService
train
protected function alterService(DockerService $service) { if ($this->internal) { $service ->setNetworks([ 'internal' ]) ->setlabels([ 'traefik.enable=false' ]); if ($this->bindPor...
php
{ "resource": "" }
q12732
DockerServiceBase.formatRunCommand
train
protected function formatRunCommand(array $commands) { $last = end($commands); return 'RUN ' . implode("\r\n && ", array_map( function ($value) use ($last) { return $last !== $value ? "{$value} \\" : $value; }, $commands )); }
php
{ "resource": "" }
q12733
DockerServiceBase.mergeConfigVariable
train
protected function mergeConfigVariable($name, array $values) { if (in_array($name, static::DOCKER_VARIABLES)) { $this->configs[$name] = array_unique( array_merge($this->configs[$name], $values) ); } return $this; }
php
{ "resource": "" }
q12734
Manager.launchNextTask
train
protected function launchNextTask() { if (! $this->numberOfThreadsToLaunch) { return false; } $taskInfos = $this->pool[$this->numberOfTasks - $this->numberOfThreadsToLaunch]; $taskInfos['task']->fork(); $this->numberOfRunningThreads++; $t...
php
{ "resource": "" }
q12735
Router.match
train
public function match($segment, array $map) { foreach ($map as $index => $uriTemplate) { $matches = array(); if (preg_match($this->createRegEx($uriTemplate), $segment, $matches) === 1) { $matchedURI = array_shift($matches); $routeMatch = new RouteMatc...
php
{ "resource": "" }
q12736
Router.createRegEx
train
private function createRegEx($uriTemplate) { $pattern = str_replace($this->getPlaceholders(), $this->getPatterns(), $uriTemplate); // Match everything after question mark, if present $pattern .= '(\?(.*))?'; return '~^' . $pattern . '$~i'; }
php
{ "resource": "" }
q12737
CacheMapper.fetchAll
train
public function fetchAll() { $query = sprintf('SELECT * FROM `%s`', $this->table); $result = array(); foreach ($this->pdo->query($query) as $key => $value) { $result[$key] = $value; } return $this->parse($result); }
php
{ "resource": "" }
q12738
CacheMapper.alter
train
private function alter($key, $operator, $step) { $query = sprintf('UPDATE `%s` SET `value` = value %s %s WHERE `key` = :key', $this->table, $operator, $step); $stmt = $this->pdo->prepare($query); return $stmt->execute(array( ':key' => $key )); }
php
{ "resource": "" }
q12739
CacheMapper.insert
train
public function insert($key, $value, $ttl, $time) { if ($this->serializer->isSerializeable($value)) { $value = $this->serializer->serialize($value); } $query = sprintf('INSERT INTO `%s` (`key`, `value`, `ttl`, `created_on`) VALUES (:key, :value, :ttl, :created_on)', $this->table...
php
{ "resource": "" }
q12740
CacheMapper.parse
train
private function parse(array $data) { $result = array(); foreach ($data as $index => $array) { if ($this->serializer->isSerialized($array[ConstProviderInterface::CACHE_PARAM_VALUE])) { $array[ConstProviderInterface::CACHE_PARAM_VALUE] = $this->serializer->unserialize($ar...
php
{ "resource": "" }
q12741
PrimeTask.insertNewFileFunctions
train
private function insertNewFileFunctions(iterable $new): void { // early return when there is nothing to be added if (0 === \count($new)) { return; } $table = $this->getTable(); $db = $this->getDb(); foreach ($new as $file_function => $data) { ...
php
{ "resource": "" }
q12742
Calculator.get
train
public function get(Carbon $dt = NULL) { if (!$dt) { $dt = new Carbon(); } /* Disregard times */ $dt->setTime(0, 0, 0); /* FY is based on the -end- of the FY, thus we will work backward to determine if we need to 'rollup' the FY from the input year */ ...
php
{ "resource": "" }
q12743
NumberBase.buildDigitList
train
private function buildDigitList($digitList) { if (is_int($digitList)) { return new IntegerDigitList($digitList); } elseif (is_string($digitList)) { return new StringDigitList($digitList); } elseif (is_array($digitList)) { return new ArrayDigitList($digitLi...
php
{ "resource": "" }
q12744
NumberBase.hasDigit
train
public function hasDigit($digit) { try { $this->digits->getValue($digit); } catch (DigitList\InvalidDigitException $ex) { return false; } return true; }
php
{ "resource": "" }
q12745
NumberBase.getValues
train
public function getValues(array $digits) { $values = []; foreach ($digits as $digit) { $values[] = $this->digits->getValue($digit); } return $values; }
php
{ "resource": "" }
q12746
NumberBase.getDigits
train
public function getDigits(array $decimals) { $digits = []; foreach ($decimals as $decimal) { $digits[] = $this->digits->getDigit($decimal); } return $digits; }
php
{ "resource": "" }
q12747
NumberBase.findCommonRadixRoot
train
public function findCommonRadixRoot(NumberBase $base) { $common = array_intersect($this->getRadixRoots(), $base->getRadixRoots()); return count($common) > 0 ? max($common) : false; }
php
{ "resource": "" }
q12748
NumberBase.getRadixRoots
train
private function getRadixRoots() { $radix = count($this->digits); $roots = [$radix]; for ($i = 2; ($root = (int) ($radix ** (1 / $i))) > 1; $i++) { if ($root ** $i === $radix) { $roots[] = $root; } } return $roots; }
php
{ "resource": "" }
q12749
NumberBase.canonizeDigits
train
public function canonizeDigits(array $digits) { $result = $this->getDigits($this->getValues($digits)); return empty($result) ? [$this->digits->getDigit(0)] : $result; }
php
{ "resource": "" }
q12750
NumberBase.splitString
train
public function splitString($string) { if ($this->digits->hasStringConflict()) { throw new \RuntimeException('The number base does not support string presentation'); } $pattern = $this->getDigitPattern(); if ((string) $string === '') { $digits = []; ...
php
{ "resource": "" }
q12751
NumberBase.getDigitPattern
train
private function getDigitPattern() { if (!isset($this->digitPattern)) { $lengths = array_map('strlen', $this->digits->getDigits()); if (count(array_flip($lengths)) === 1) { $this->digitPattern = array_pop($lengths); } else { $this->digitPa...
php
{ "resource": "" }
q12752
ValidatorChain.isValid
train
public function isValid() { foreach ($this->validators as $validator) { if (!$validator->isValid()) { // Prepare error messages foreach ($validator->getErrors() as $name => $messages) { if (!isset($this->errors[$name])) { ...
php
{ "resource": "" }
q12753
Href.replace
train
public function replace( $key, $value ) { if($value === "" || is_null($value) || $value === false) { $this->url = preg_replace("#/{" . $key . "}.*$#", "", $this->getUrl()); } else { $this->url = str_replace("{" . $key . "}", $value, $this->getUrl()); } return...
php
{ "resource": "" }
q12754
Href.validate
train
public function validate() { if (!$this->isValid( $this->getUrl() )) { throw new InvalidUrl( sprintf( '"%s" is not a valid url', $this->url ) ); } return $this; }
php
{ "resource": "" }
q12755
EventTaskBase.executeCommandHook
train
protected function executeCommandHook($method, $event_type) { foreach ($this->getCommandsByMethodEventType($method, $event_type) as $command) { if (is_string($command)) { $command = (new CommandHook()) ->setType('raw') ->setCommand($command...
php
{ "resource": "" }
q12756
EventTaskBase.executeEngineCmdHook
train
protected function executeEngineCmdHook(CommandHookInterface $hook_command) { $options = $hook_command->getOptions(); // Determine the service the command should be ran inside. $service = isset($options['service']) ? $options['service'] : null; // Determine ...
php
{ "resource": "" }
q12757
EventTaskBase.resolveHookCommand
train
protected function resolveHookCommand(CommandHookInterface $command_hook) { $command = null; switch ($command_hook->getType()) { case 'raw': $command = $command_hook->getCommand(); break; case 'engine': $command = $this->getEng...
php
{ "resource": "" }
q12758
EventTaskBase.executeSymfonyCmdHook
train
protected function executeSymfonyCmdHook(CommandHookInterface $command_hook, $method) { $command = $command_hook->getCommand(); $container = ProjectX::getContainer(); $application = $container->get('application'); try { $info = $this->getCommandInfo($method); ...
php
{ "resource": "" }
q12759
EventTaskBase.getProjectCommand
train
protected function getProjectCommand(CommandHookInterface $command_hook) { $method = $command_hook->getCommand(); $project = $this->getProjectInstance(); if (!method_exists($project, $method)) { throw new CommandHookRuntimeException( sprintf("The %s method doesn'...
php
{ "resource": "" }
q12760
EventTaskBase.getEngineCommand
train
protected function getEngineCommand(CommandHookInterface $command_hook) { $method = $command_hook->getCommand(); $engine = $this->getEngineInstance(); if (!method_exists($engine, $method)) { throw new CommandHookRuntimeException( sprintf("The %s method doesn't ex...
php
{ "resource": "" }
q12761
EventTaskBase.getCommandsByMethodEventType
train
protected function getCommandsByMethodEventType($method, $event_type) { $hooks = ProjectX::getProjectConfig()->getCommandHooks(); if (empty($hooks)) { return []; } $info = $this->getCommandInfo($method); list($command, $action) = explode(':', $info->getName()); ...
php
{ "resource": "" }
q12762
RedisProxy.setDriversOrder
train
public function setDriversOrder(array $driversOrder) { foreach ($driversOrder as $driver) { if (!in_array($driver, $this->supportedDrivers)) { throw new RedisProxyException('Driver "' . $driver . '" is not supported'); } } $this->driversOrder = $driver...
php
{ "resource": "" }
q12763
RedisProxy.exists
train
public function exists($key) { $this->init(); $result = $this->driver->exists($key); return (bool)$result; }
php
{ "resource": "" }
q12764
RedisProxy.get
train
public function get($key) { $this->init(); $result = $this->driver->get($key); return $this->convertFalseToNull($result); }
php
{ "resource": "" }
q12765
RedisProxy.getset
train
public function getset($key, $value) { $this->init(); $result = $this->driver->getset($key, $value); return $this->convertFalseToNull($result); }
php
{ "resource": "" }
q12766
RedisProxy.expire
train
public function expire($key, $seconds) { $this->init(); $result = $this->driver->expire($key, $seconds); return (bool)$result; }
php
{ "resource": "" }
q12767
RedisProxy.pexpire
train
public function pexpire($key, $miliseconds) { $this->init(); $result = $this->driver->pexpire($key, $miliseconds); return (bool)$result; }
php
{ "resource": "" }
q12768
RedisProxy.expireat
train
public function expireat($key, $timestamp) { $this->init(); $result = $this->driver->expireat($key, $timestamp); return (bool)$result; }
php
{ "resource": "" }
q12769
RedisProxy.pexpireat
train
public function pexpireat($key, $milisecondsTimestamp) { $this->init(); $result = $this->driver->pexpireat($key, $milisecondsTimestamp); return (bool)$result; }
php
{ "resource": "" }
q12770
RedisProxy.psetex
train
public function psetex($key, $miliseconds, $value) { $this->init(); $result = $this->driver->psetex($key, $miliseconds, $value); if ($result == '+OK') { return true; } return $this->transformResult($result); }
php
{ "resource": "" }
q12771
RedisProxy.persist
train
public function persist($key) { $this->init(); $result = $this->driver->persist($key); return (bool)$result; }
php
{ "resource": "" }
q12772
RedisProxy.setnx
train
public function setnx($key, $value) { $this->init(); $result = $this->driver->setnx($key, $value); return (bool)$result; }
php
{ "resource": "" }
q12773
RedisProxy.incrby
train
public function incrby($key, $increment = 1) { $this->init(); return $this->driver->incrby($key, (int)$increment); }
php
{ "resource": "" }
q12774
RedisProxy.incrbyfloat
train
public function incrbyfloat($key, $increment = 1) { $this->init(); return $this->driver->incrbyfloat($key, $increment); }
php
{ "resource": "" }
q12775
RedisProxy.decrby
train
public function decrby($key, $decrement = 1) { $this->init(); return $this->driver->decrby($key, (int)$decrement); }
php
{ "resource": "" }
q12776
RedisProxy.dump
train
public function dump($key) { $this->init(); $result = $this->driver->dump($key); return $this->convertFalseToNull($result); }
php
{ "resource": "" }
q12777
RedisProxy.mset
train
public function mset(...$dictionary) { $this->init(); if (is_array($dictionary[0])) { $result = $this->driver->mset(...$dictionary); return $this->transformResult($result); } $dictionary = $this->prepareKeyValue($dictionary, 'mset'); $result = $this->d...
php
{ "resource": "" }
q12778
RedisProxy.hdel
train
public function hdel($key, ...$fields) { $fields = $this->prepareArguments('hdel', ...$fields); $this->init(); return $this->driver->hdel($key, ...$fields); }
php
{ "resource": "" }
q12779
RedisProxy.hincrby
train
public function hincrby($key, $field, $increment = 1) { $this->init(); return $this->driver->hincrby($key, $field, (int)$increment); }
php
{ "resource": "" }
q12780
RedisProxy.hincrbyfloat
train
public function hincrbyfloat($key, $field, $increment = 1) { $this->init(); return $this->driver->hincrbyfloat($key, $field, $increment); }
php
{ "resource": "" }
q12781
RedisProxy.hmset
train
public function hmset($key, ...$dictionary) { $this->init(); if (is_array($dictionary[0])) { $result = $this->driver->hmset($key, ...$dictionary); return $this->transformResult($result); } $dictionary = $this->prepareKeyValue($dictionary, 'hmset'); $re...
php
{ "resource": "" }
q12782
RedisProxy.hmget
train
public function hmget($key, ...$fields) { $fields = array_unique($this->prepareArguments('hmget', ...$fields)); $this->init(); $values = []; foreach ($this->driver->hmget($key, $fields) as $value) { $values[] = $this->convertFalseToNull($value); } return a...
php
{ "resource": "" }
q12783
RedisProxy.sadd
train
public function sadd($key, ...$members) { $members = $this->prepareArguments('sadd', ...$members); $this->init(); return $this->driver->sadd($key, ...$members); }
php
{ "resource": "" }
q12784
RedisProxy.spop
train
public function spop($key, $count = 1) { $this->init(); if ($count == 1 || $count === null) { $result = $this->driver->spop($key); return $this->convertFalseToNull($result); } $members = []; for ($i = 0; $i < $count; ++$i) { $member = $thi...
php
{ "resource": "" }
q12785
RedisProxy.sscan
train
public function sscan($key, &$iterator, $pattern = null, $count = null) { if ((string)$iterator === '0') { return null; } $this->init(); if ($this->actualDriver() === self::DRIVER_PREDIS) { $returned = $this->driver->sscan($key, $iterator, ['match' => $pattern...
php
{ "resource": "" }
q12786
RedisProxy.rpush
train
public function rpush($key, ...$elements) { $elements = $this->prepareArguments('rpush', ...$elements); $this->init(); return $this->driver->rpush($key, ...$elements); }
php
{ "resource": "" }
q12787
RedisProxy.lpop
train
public function lpop($key) { $this->init(); $result = $this->driver->lpop($key); return $this->convertFalseToNull($result); }
php
{ "resource": "" }
q12788
RedisProxy.rpop
train
public function rpop($key) { $this->init(); $result = $this->driver->rpop($key); return $this->convertFalseToNull($result); }
php
{ "resource": "" }
q12789
RedisProxy.zadd
train
public function zadd($key, ...$dictionary) { $this->init(); if (is_array($dictionary[0])) { $return = 0; foreach ($dictionary[0] as $member => $score) { $res = $this->zadd($key, $score, $member); $return += $res; } retur...
php
{ "resource": "" }
q12790
RedisProxy.zrevrange
train
public function zrevrange($key, $start, $stop, $withscores = false) { $this->init(); if ($this->actualDriver() === self::DRIVER_PREDIS) { return $this->driver->zrevrange($key, $start, $stop, ['WITHSCORES' => $withscores]); } return $this->driver->zrevrange($key, $start, $...
php
{ "resource": "" }
q12791
RedisProxy.convertFalseToNull
train
private function convertFalseToNull($result) { return $this->actualDriver() === self::DRIVER_REDIS && $result === false ? null : $result; }
php
{ "resource": "" }
q12792
RedisProxy.transformResult
train
private function transformResult($result) { if ($this->actualDriver() === self::DRIVER_PREDIS && $result instanceof Status) { $result = $result->getPayload() === 'OK'; } return $result; }
php
{ "resource": "" }
q12793
RedisProxy.prepareKeyValue
train
private function prepareKeyValue(array $dictionary, $command) { $keys = array_values(array_filter($dictionary, function ($key) { return $key % 2 == 0; }, ARRAY_FILTER_USE_KEY)); $values = array_values(array_filter($dictionary, function ($key) { return $key % 2 == 1; ...
php
{ "resource": "" }
q12794
Dumper.dump
train
public static function dump($variable, $exit = true) { if (is_object($variable) && method_exists($variable, '__toString')) { echo $variable; } else { if (is_bool($variable)) { var_dump($variable); } else { $text = sprintf('<pre>%s<...
php
{ "resource": "" }
q12795
Bootstrap.router
train
public static function router($directory, $config = 'config.yml') { $request = Server::get('PHP_SELF'); $root = Server::get('DOCUMENT_ROOT'); $file = $root . $request; if(file_exists($file) && !is_dir($file)) { return false; } else ...
php
{ "resource": "" }
q12796
Bootstrap.init
train
public function init() { Profiler::start('init', 'init'); $this->initTime = microtime(true); $this->init = true; Log::d('Initializing framework...'); // $this->register_error_handler(); date_default_timezone_set('Europe/Madrid'); $this->setupLanguage();...
php
{ "resource": "" }
q12797
Bootstrap.install
train
public function install() { define('GL_INSTALL', true); $this->init(); echo '<pre>'; $fail = false; $db = new DatabaseManager(); if ($db->connectAndSelect()) { $this->setDatabase($db); $this->log('Connection to database ok'); ...
php
{ "resource": "" }
q12798
InstanceBuilder.build
train
public function build($class, array $args) { // Normalize class name $class = $this->normalizeClassName($class); if (isset($this->cache[$class])) { return $this->cache[$class]; } else { if (class_exists($class, true)) { $instance = $this->getI...
php
{ "resource": "" }
q12799
InstanceBuilder.getInstance
train
private function getInstance($class, array $args) { // Hack to avoid Reflection for most cases switch (count($args)) { case 0: return new $class; case 1: return new $class($args[0]); case 2: return new $class($args[0...
php
{ "resource": "" }