_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q30300 | XmlSerializationVisitor.createDocument | train | private function createDocument(?string $version = null, ?string $encoding = null): \DOMDocument
{
$doc = new \DOMDocument($version ?: $this->defaultVersion, $encoding ?: $this->defaultEncoding);
$doc->formatOutput = true;
return $doc;
} | php | {
"resource": ""
} |
q30301 | RecordConverter.ip2locationRecord | train | public static function ip2locationRecord( $record ) {
if ( isset( $record['error'] ) ) {
throw new \Exception( $record['error'] );
}
self::$geot_record = [];
self::$geot_record['city']['names'] = isset( $record['cityName'] ) ? [ 'en' => $record['cityName'] ... | php | {
"resource": ""
} |
q30302 | RepeatedSlotsAligner.align | train | public function align(Template $template, array $templateSlots)
{
$slots = array_flip($template->getSlots());
if (empty($templateSlots) || empty($slots)) {
return null;
}
$templateName = strtolower($template->getTemplateName());
$templateSlots = array_intersect_k... | php | {
"resource": ""
} |
q30303 | RepeatedSlotsAligner.updateSlotStatus | train | protected function updateSlotStatus(array $templateSlots, array $changedSlots)
{
try {
$result = true;
$this->blockRepository->startTransaction();
foreach ($changedSlots as $slotName => $repeated) {
$converter = $this->slotsConverterFactory->createConverte... | php | {
"resource": ""
} |
q30304 | RepeatedSlotsAligner.templateSlotsToArray | train | protected function templateSlotsToArray($slots)
{
$result = array();
foreach ($slots as $slot) {
$result[$slot->getSlotName()] = $slot->getRepeated();
}
return $result;
} | php | {
"resource": ""
} |
q30305 | Configuration.configureOptions | train | protected function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'csrf_parameter' => '_csrf_token',
'csrf_protection' => true,
'collection_type' => FormCollectionInterface::COLLECTION_TYPE_ALL,
'locale' => 'en_EN',
'fa... | php | {
"resource": ""
} |
q30306 | RequestId._generateBytesWithMtRand | train | protected function _generateBytesWithMtRand($amt)
{
$tmp = array();
for ($idx = 0; $idx < $amt; $idx++) {
$tmp[] = chr($this->_mtRand(0, 255));
}
return join('', $tmp);
} | php | {
"resource": ""
} |
q30307 | RequestId._generateUUIDFromData | train | private function _generateUUIDFromData($data)
{
$data = substr($data, 0, 16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set the '4' in block 3
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits for block 4
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data)... | php | {
"resource": ""
} |
q30308 | ImageSizer.widen | train | public function widen($img, $width, $outputFormat = null, $targetPath = null)
{
if ($targetPath && $this->cache->cached($targetPath)) {
return;
}
list($ow, $oh) = $imgInfo = ImageFile::getSize($img);
$srcImg = ImageFile::get($img, $imgInfo);
if ($width == $ow) {... | php | {
"resource": ""
} |
q30309 | ImageSizer.maximize | train | public function maximize($img, $maxWidth, $maxHeight, $outputFormat = null, $targetPath = null)
{
if ($targetPath && $this->cache->cached($targetPath)) {
return;
}
list($ow, $oh) = $imgInfo = ImageFile::getSize($img);
$srcImg = ImageFile::get($img, $imgInfo);
//... | php | {
"resource": ""
} |
q30310 | ImageSizer.thumbnail | train | public function thumbnail($img, $width, $height, $outputFormat = null, $targetPath = null)
{
if ($targetPath && $this->cache->cached($targetPath)) {
return;
}
list($ow, $oh) = $imgInfo = ImageFile::getSize($img);
$srcImg = ImageFile::get($img, $imgInfo);
// calc... | php | {
"resource": ""
} |
q30311 | Verifier.getContent | train | public function getContent($asResource = false)
{
$content = $this->request->getContent($asResource);
json_decode($content);
if (json_last_error() == JSON_ERROR_NONE) {
return json_encode(json_decode($content), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
... | php | {
"resource": ""
} |
q30312 | Verifier.isValid | train | public function isValid(string $key) : bool
{
if (!$this->headers->has($this->algorithmHeader)) {
return false;
}
if (!$this->headers->has($this->signatureHeader)) {
return false;
}
$signature = new Signature(new Payload($this->request), $this->getAl... | php | {
"resource": ""
} |
q30313 | Verifier.isExpired | train | public function isExpired(int $tolerance) : bool
{
$timestamp = $this->headers->get('X-SIGNED-TIMESTAMP', '1901-01-01 12:00:00');
$issuedAt = Carbon::parse($timestamp);
$isValid = Helpers::verifyDateTime($timestamp, 'Y-m-d H:i:s');
return !$isValid || Carbon::now()->diffInSeconds($... | php | {
"resource": ""
} |
q30314 | Bootstrap.useStreamWrappers | train | public static function useStreamWrappers() {
$swift = stream_wrapper_register(
\HPCloud\Storage\ObjectStorage\StreamWrapper::DEFAULT_SCHEME,
'\HPCloud\Storage\ObjectStorage\StreamWrapper'
);
$swiftfs = stream_wrapper_register(
\HPCloud\Storage\ObjectStorage\StreamWrapperFS::DEFAULT_SCHEME... | php | {
"resource": ""
} |
q30315 | Bootstrap.autoload | train | public static function autoload($klass) {
$components = explode('\\', $klass);
if (empty($components[0])) {
array_shift($components);
}
// This class loader ONLY loads
// our classes. A general purpose
// classloader should be used for
// more sophisticated needs.
if ($components[... | php | {
"resource": ""
} |
q30316 | Bootstrap.config | train | public static function config($name = NULL, $default = NULL) {
// If no name is specified, return the entire config array.
if (empty($name)) {
return self::$config;
}
// If the config value exists, return that.
if (isset(self::$config[$name])) {
return self::$config[$name];
}
... | php | {
"resource": ""
} |
q30317 | eZHTTPCacheManager.getHandlerList | train | public static function getHandlerList()
{
$handlerList = array();
$ini = eZINI::instance( 'http.ini' );
if ( $ini->hasGroup( 'HTTPCacheHandlers' ) && $ini->hasVariable( 'HTTPCacheHandlers', 'Handlers' ) )
$handlerList = $ini->variable( 'HTTPCacheHandlers', 'Handlers' );
... | php | {
"resource": ""
} |
q30318 | eZHTTPCacheManager.getHandlers | train | public static function getHandlers()
{
$handlers = array();
$handlerList = self::getHandlerList();
$cacheHash = md5( serialize( $handlerList ) );
if ( isset( $GLOBALS['eZHTTPCacheManager_' . $cacheHash] ) )
return $GLOBALS['eZHTTPCacheManager_' . $cacheHash];
... | php | {
"resource": ""
} |
q30319 | eZHTTPCacheManager.execute | train | public static function execute( $url )
{
$handlers = self::getHandlers();
foreach ( $handlers as $handler )
{
if ( $handler->isEnabled() )
$handler->purgeURL( $url );
}
} | php | {
"resource": ""
} |
q30320 | Aes_4.AES | train | function AES($z)
{
$this->Nb = 4;
$this->Nk = strlen($z) / 4;
$this->Nr = $this->Nk + $this->Nb + 2;
if ($this->Nk != 4 && $this->Nk != 6 && $this->Nk != 8) die("Key is " . ($this->Nk * 32) . " bits long. *not* 128, 192, or 256.");
$this->Nr = $this->Nk + $this->Nb + 2;
... | php | {
"resource": ""
} |
q30321 | ErrorHandler.handler | train | public function handler($errno, $errstr, $errfile, $errline)
{
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
} | php | {
"resource": ""
} |
q30322 | Flash.settings | train | public static function settings($settings=array())
{
self::$_readOnce = isset($settings['readOnce']) ? (boolean) $settings['readOnce'] : false;
self::$_defaultReturn = (array_key_exists('defaultReturn',$settings)) ? $settings['defaultReturn'] : 'ST__EXCEPTION';
} | php | {
"resource": ""
} |
q30323 | Flash._cleanPrevious | train | protected static function _cleanPrevious()
{
if(self::$_cleanedPrev) return true;
self::$_cleanedPrev = 1;
if(isset($_SESSION) && is_array($_SESSION)) {
foreach ($_SESSION as $key => $value) {
if (strpos($key, self::$_sessionKey) === 0) {
if ($_SES... | php | {
"resource": ""
} |
q30324 | Flash.reflush | train | public static function reflush($keys=null)
{
self::_cleanPrevious();
if($keys)
{
if(!is_array($keys))
{
$keys = array($keys);
}
$keys = array_flip($keys);
}
foreach($_SESSION as $key => $value)
{
if(strpos($key,self::$_sessionKey)===0)
{
if($keys)
{
$k... | php | {
"resource": ""
} |
q30325 | PageTreeCollection.fill | train | public function fill()
{
$languages = $this->languageRepository->activeLanguages();
$this->initPages($languages);
$this->initBasePages($languages);
} | php | {
"resource": ""
} |
q30326 | ConfigMailLoader.createMail | train | protected function createMail(array $config)
{
$mail = $this->newMailInstance();
$mail->setName(ConfigUtil::getValue($config, 'name'));
$mail->setLabel(ConfigUtil::getValue($config, 'label'));
$mail->setDescription(ConfigUtil::getValue($config, 'description'));
$mail->setTyp... | php | {
"resource": ""
} |
q30327 | ConfigMailLoader.createMailTranslation | train | protected function createMailTranslation(MailInterface $mail, array $config)
{
$translation = $this->newMailTranslationInstance($mail);
$translation->setLocale(ConfigUtil::getValue($config, 'locale'));
$translation->setLabel(ConfigUtil::getValue($config, 'label'));
$translation->setD... | php | {
"resource": ""
} |
q30328 | ImageThumbnailExtension.thumbnail | train | public function thumbnail($image, $targetWidth = 100, $targetHeight = 100)
{
$imagePath = $this->container->getParameter('red_kite_cms.web_folder_full_path') . $image;
if (!is_file($imagePath)) {
return null;
}
$thumbnailer = $this->container->get('red_kite_cms.images_thu... | php | {
"resource": ""
} |
q30329 | BlockManagerFactory.addBlockManager | train | public function addBlockManager(BlockManagerInterface $blockManager, array $attributes)
{
if (empty($attributes['type'])) {
return;
}
$blockManager->setFactoryRepository($this->factoryRepository);
$this->blockManagersItems[] = new BlockManagerFactoryItem($blockManager, $... | php | {
"resource": ""
} |
q30330 | BlockManagerFactory.getBlocks | train | public function getBlocks()
{
$ungroupedKey = 'Ungrouped';
$blockGroups = array();
foreach ($this->blockManagersItems as $blockManagerItem) {
if ($blockManagerItem->getBlockManager()->getIsInternalBlock()) {
continue;
}
$groups = array($u... | php | {
"resource": ""
} |
q30331 | Container.register | train | public function register($id, $definition, $shared = false)
{
if (is_object($definition) && !is_callable($definition)) {
$this->instances[$id] = $definition;
return $this;
}
$this->components[$id] = $definition;
if ($shared || isset($this->instances[$id])) ... | php | {
"resource": ""
} |
q30332 | Container.unregister | train | public function unregister($id)
{
if (array_key_exists($id, $this->components)) {
unset($this->components[$id]);
}
if (array_key_exists($id, $this->instances)) {
unset($this->instances[$id]);
}
return $this;
} | php | {
"resource": ""
} |
q30333 | Container.exists | train | public function exists($id)
{
if (array_key_exists($id, $this->components)) {
return true;
}
if (isset($this->instances[$id])) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q30334 | Container.& | train | public function &get($id)
{
if (isset($this->instances[$id])) {
return $this->instances[$id];
}
$result = $this->resolve($id);
if (array_key_exists($id, $this->instances)) {
$this->instances[$id] = & $result;
}
return $result;
} | php | {
"resource": ""
} |
q30335 | Container.resolve | train | protected function resolve($id)
{
$keys = explode(self::SEPARATOR, $id);
$node = & $this->components;
while ($key = array_shift($keys)) {
if (!is_array($node) || !array_key_exists($key, $node)) {
throw new ContainerException(sprintf('Invalid or unknown component/... | php | {
"resource": ""
} |
q30336 | PhpbbPassword.encode64 | train | private function encode64($input, $count) {
$output = '';
$i = 0;
do {
$value = ord($input[$i++]);
$output .= self::$itoa64[$value & 0x3f];
if ($i < $count) {
$value |= ord($input[$i]) << 8;
}
$output .= self::$itoa64... | php | {
"resource": ""
} |
q30337 | EditSeoListener.onBeforeEditPageCommit | train | public function onBeforeEditPageCommit(BeforeEditPageCommitEvent $event)
{
if ($event->isAborted()) {
return;
}
$pageManager = $event->getContentManager();
$pageRepository = $pageManager->getPageRepository();
$values = $event->getValues();
if (!is_array(... | php | {
"resource": ""
} |
q30338 | Instantiator.getClassIndex | train | public function getClassIndex(): ClassIndex
{
if (is_null($this->classIndex)) {
$this->classIndex = new ClassIndex();
}
return $this->classIndex;
} | php | {
"resource": ""
} |
q30339 | Instantiator.newInstanceOf | train | public function newInstanceOf($class, array $arguments = [], bool $dependencyInjection = true)
{
try {
// Reflection of class
$reflectionClass = new \ReflectionClass($class);
if (!is_null($constructor = $reflectionClass->getConstructor())) {
// Dependency... | php | {
"resource": ""
} |
q30340 | Instantiator.invokeMethod | train | public function invokeMethod($class, string $method, array $arguments = [], bool $dependencyInjection = true)
{
// Check validity of first argument
if (!(is_object($class) || (is_string($class) && class_exists($class)))) {
throw new InstantiatorException(sprintf('First argument must be a... | php | {
"resource": ""
} |
q30341 | Instantiator.invokeFunction | train | public function invokeFunction(string $function, array $arguments = [], bool $dependencyInjection = true)
{
try {
// Reflection of function
$reflectionFunction = new \ReflectionFunction($function);
// Dependency injection?
if ($dependencyInjection) {
... | php | {
"resource": ""
} |
q30342 | Instantiator.getDependencyInjectionParameters | train | private function getDependencyInjectionParameters(array $reflectionParameters, array $arguments = []): array
{
$parameters = [];
// Treat arguments
$argumentsClass = [];
foreach ($arguments as $name => &$argument) {
if (!is_null($this->getContainer())) {
... | php | {
"resource": ""
} |
q30343 | Instantiator.getDependencyInjectionParameter | train | private function getDependencyInjectionParameter(\ReflectionParameter $reflectionParameter, array &$arguments, array $argumentsClass)
{
// Parameter name in arguments list?
if (array_key_exists($reflectionParameter->getName(), $arguments)) {
$parameter = $arguments[$reflectionParameter->... | php | {
"resource": ""
} |
q30344 | FlashBag.add | train | public function add($message, $type = 'error')
{
$this->session[$this->prefix][] = ['message' => $message, 'type' => $type];
return $this;
} | php | {
"resource": ""
} |
q30345 | FlashBag.has | train | public function has($type = null)
{
if ($type === null) {
return !empty($this->session[$this->prefix]);
}
foreach ($this->session[$this->prefix] as $message) {
if ($message['type'] === $type) {
return true;
}
}
return fals... | php | {
"resource": ""
} |
q30346 | FlashBag.get | train | public function get($type = null)
{
$result = [];
foreach ($this->session[$this->prefix] as $offset => $message) {
if ($type === null || $message['type'] === $type) {
$result[] = $message;
unset($this->session[$this->prefix][$offset]);
}
... | php | {
"resource": ""
} |
q30347 | Middleware.returnMiddleware | train | public function returnMiddleware(App $app, array $objects, array $middleware)
{
if (isset($middleware['arguments'])) {
$params = $middleware['arguments'];
$count = count($params);
} else {
$count = 0;
}
foreach ($params as $k => $v) {
i... | php | {
"resource": ""
} |
q30348 | TextElement.containsEscapeCharacters | train | private static function containsEscapeCharacters($string)
{
$escapeCodePattern = '#' . static::ANSI_ESCAPE_CODE_REGEX . '#';
$result = preg_match($escapeCodePattern, $string);
return (boolean) $result;
} | php | {
"resource": ""
} |
q30349 | GameController.drawAction | train | public function drawAction()
{
$this->checkGame();
$winningEntries = $this->getAdminGameService()->draw($this->game);
$content = "\xEF\xBB\xBF"; // UTF-8 BOM
$content .= "ID;Pseudo;Nom;Prenom;E-mail;Etat\n";
foreach ($winningEntries as $e) {
$etat = 'gagnant';
... | php | {
"resource": ""
} |
q30350 | GameController.exportAction | train | public function exportAction()
{
$this->checkGame();
$content = serialize($this->game);
$response = $this->getResponse();
$headers = $response->getHeaders();
$headers->addHeaderLine('Content-Encoding: UTF-8');
$headers->addHeaderLine('Content-Type', 'text/plain; char... | php | {
"resource": ""
} |
q30351 | GameController.importAction | train | public function importAction()
{
$form = $this->getServiceLocator()->get('playgroundgame_import_form');
$form->setAttribute('action', $this->adminUrl()->fromRoute('playgroundgame/import'));
$form->setAttribute('method', 'post');
if ($this->getRequest()->isPost()) {
... | php | {
"resource": ""
} |
q30352 | CurlRequest.getInfo | train | public function getInfo($opt = null)
{
if ($opt !== null) {
return curl_getinfo($this->handle, $opt);
}
return curl_getinfo($this->handle);
} | php | {
"resource": ""
} |
q30353 | Router.registerNamedRoute | train | public function registerNamedRoute(Route $routeObj)
{
$name = $routeObj->getName();
if ($name && isset($this->namedRoutes[$name])) {
if ($routeObj !== $this->namedRoutes[$name]) {
throw new Exception("Can not redeclare route '{$name}'");
}
} else {
... | php | {
"resource": ""
} |
q30354 | Router.get | train | public static function get($route, $target, $name = null, $middleware = null)
{
return static::getInstance()
->map('GET', $route, $target, $name, $middleware);
} | php | {
"resource": ""
} |
q30355 | Router.post | train | public static function post($route, $target, $name = null, $middleware = null)
{
return static::getInstance()
->map('POST', $route, $target, $name, $middleware);
} | php | {
"resource": ""
} |
q30356 | Router.patch | train | public static function patch($route, $target, $name = null, $middleware = null)
{
return static::getInstance()
->map('PATCH', $route, $target, $name, $middleware);
} | php | {
"resource": ""
} |
q30357 | Router.delete | train | public static function delete($route, $target, $name = null, $middleware = null)
{
return static::getInstance()
->map('DELETE', $route, $target, $name, $middleware);
} | php | {
"resource": ""
} |
q30358 | Router.put | train | public static function put($route, $target, $name = null, $middleware = null)
{
return static::getInstance()
->map('PUT', $route, $target, $name, $middleware);
} | php | {
"resource": ""
} |
q30359 | Router.view | train | public static function view($route, $view, $data = [], $name = null, $middleware = null)
{
$target = function () use ($view, $data) {
return view($view, $data);
};
return static::get($route, $target, $name, $middleware);
} | php | {
"resource": ""
} |
q30360 | Router.redirect | train | public static function redirect($route, $to, $name = null, $middleware = null)
{
$target = function () use ($to) {
if (!filter_var($to, FILTER_VALIDATE_URL)) {
$to = static::getInstance()->route($to);
}
return redirect($to, 301);
};
retur... | php | {
"resource": ""
} |
q30361 | Router.group | train | public static function group(array $attributes, Closure $closure)
{
$hash = uniqid('prop_');
//Add options
if (isset($attributes['prefix'])) {
static::$groupsProps['prefix'][$hash] = $attributes['prefix'];
}
if (isset($attributes['namespace'])) {
stati... | php | {
"resource": ""
} |
q30362 | Helpers.verifyDateTime | train | public static function verifyDateTime(string $datetime, string $format): bool
{
$formatted = DateTime::createFromFormat($format, $datetime);
$errors = DateTime::getLastErrors();
if (!empty($errors['warning_count'])) {
return false;
}
return $formatted !== false... | php | {
"resource": ""
} |
q30363 | Model.getIndexRecords | train | public static function getIndexRecords($request, $parameters)
{
$instance = new static;
if(method_exists($instance, 'addToGetIndexRecords'))
$query = $instance->addToGetIndexRecords($request, $parameters);
else
if(method_exists($instance, 'scopeBuilder'))
... | php | {
"resource": ""
} |
q30364 | Model.deleteLangDataRecord | train | public static function deleteLangDataRecord($parameters)
{
$instance = new static;
$object = $instance::find($parameters['id']);
if($object != null)
{
$jsonObject = json_decode($object->{'data_lang_' . $instance->suffix});
//unset isn't correct, get er... | php | {
"resource": ""
} |
q30365 | Model.checkSlug | train | public static function checkSlug($slugField, $slug, $id = null)
{
$instance = new static;
$slug = $slug;
$query = $instance->where($slugField, $slug);
if($id != null)
{
$query->whereNotIn($instance->getKeyName(), [$id]);
}
$nObjects = $query... | php | {
"resource": ""
} |
q30366 | GearmanTransport.doSendRequest | train | protected function doSendRequest(Request $request): Response
{
if (!$this->shouldUseGearman()) {
return $this->locator->getRequestBus()->receiveRequest($request);
}
$envelope = new TransportEnvelope($request, 'php');
$channel = $this->router->forRequest($request);
... | php | {
"resource": ""
} |
q30367 | GearmanTransport.destroyClient | train | private function destroyClient(): void
{
++$this->reconnects;
$this->client = null;
$delay = mt_rand(0, (int)min(5000, (int)pow(2, $this->reconnects) * 100));
usleep($delay * 1000);
} | php | {
"resource": ""
} |
q30368 | GearmanTransport.getClient | train | private function getClient(): \GearmanClient
{
if (null === $this->client) {
$client = new \GearmanClient();
$client->setTimeout($this->timeout);
if (empty($this->servers)) {
try {
// by default we add the local machine
... | php | {
"resource": ""
} |
q30369 | GearmanTransport.validateReturnCode | train | private function validateReturnCode(\GearmanClient $client, string $channel): void
{
switch ($client->returnCode()) {
case GEARMAN_SUCCESS:
case GEARMAN_WORK_DATA:
case GEARMAN_WORK_STATUS:
return;
case GEARMAN_TIMEOUT:
throw n... | php | {
"resource": ""
} |
q30370 | PageBlocks.getBlockTypes | train | public function getBlockTypes()
{
$types = array();
foreach ($this->alBlocks as $block) {
$type = $block->getType();
if ( !in_array($type, $types)) {
$types[] = $type;
}
}
return $types;
} | php | {
"resource": ""
} |
q30371 | PageBlocks.arrangeBlocks | train | protected function arrangeBlocks()
{
$this->blocks = array();
foreach ($this->alBlocks as $alBlock) {
$this->blocks[$alBlock->getSlotName()][] = $alBlock;
}
} | php | {
"resource": ""
} |
q30372 | Router.match | train | public function match(RequestInterface $request)
{
foreach ($this->routes as $name => $route) {
if (!$route->match($request)) {
continue;
}
foreach ($route->arguments() as $key => $value) {
$request->query()
->set($key,... | php | {
"resource": ""
} |
q30373 | Router.make | train | public function make($name = null, array $arguments = [])
{
$name = $this->resolveName($name);
if (is_scalar($name) && isset($this->routes[$name])) {
return $this->routes[$name]->make($this->defaults['host'], $arguments);
}
foreach ($this->routes as $route) {
... | php | {
"resource": ""
} |
q30374 | Router.resolveName | train | private function resolveName($name)
{
if ($name !== null) {
return $name;
}
if (!isset($this->defaults['route'])) {
throw new RouterException('Unable to make "self" url - default route was not defined.');
}
return $this->defaults['route'];
} | php | {
"resource": ""
} |
q30375 | ShardUtils.determineShard | train | public static function determineShard($string, int $shards = 256): int
{
// first 4 chars of md5 give us a 16 bit keyspace (0-65535)
$num = hexdec(substr(md5((string)$string), 0, 4));
return $num % $shards;
} | php | {
"resource": ""
} |
q30376 | SliderWidget.createSlider | train | protected function createSlider()
{
$this->data['slideWidth'] = $this->sliderWidth;
$this->data['slideHeight'] = $this->sliderHeight;
$this->data['slidePosition'] = ['left' => 0, 'top' => 0];
$this->data['arrowSkinId'] = $this->arrowSkinId;
$this->data['navSkinId'] = $this->n... | php | {
"resource": ""
} |
q30377 | SliderWidget.createSliderContainer | train | protected function createSliderContainer()
{
//Slider container
$customCssClass = isset($this->containerOptions['class']) ? ' ' . $this->containerOptions['class'] : '';
$this->containerOptions = [];
$this->containerOptions['style'] = "width:{$this->sliderWidth}px; height:{$this->sliderHeight... | php | {
"resource": ""
} |
q30378 | SliderWidget.createSliderArrow | train | protected function createSliderArrow()
{
$skin = self::$arrowSkins[$this->arrowSkinId];
//$this->data['arrow']['top'] = 0;
// $this->data['arrow']['top'] = floor($this->data['slideHeight'] / 2);
$this->data['arrow']['left'] = $skin['left'];
$this->data['arrow']['right'] = $skin['right'];
... | php | {
"resource": ""
} |
q30379 | SliderWidget.createSliderBullet | train | protected function createSliderBullet()
{
$skin = self::$navSkins[$this->navSkinId];
$skin['s']['$Class'] = '$JssorBulletNavigator$';
$this->mergeSkinSettings($skin, '$BulletNavigatorOptions');
} | php | {
"resource": ""
} |
q30380 | SliderWidget.createSliderThumb | train | protected function createSliderThumb()
{
$skin = self::$navSkins[$this->navSkinId];
//Set default value for thumb positon becauce not all skins need this value
$this->data['template'] = $skin['template'];
if ($skin['position'] === 'bottom') {
$this->data['thumb']['contain... | php | {
"resource": ""
} |
q30381 | SliderWidget.resolvePosition | train | protected function resolvePosition($positions)
{
$str = '';
foreach ($positions as $pos => $val) {
$str .= "{$pos}: {$val}px; ";
}
return rtrim($str);
} | php | {
"resource": ""
} |
q30382 | PoolsPass.process | train | public function process(ContainerBuilder $container)
{
$this->setupPools($container);
$pools = $container->getParameter('gendoria_command_queue.pools');
foreach ($container->findTaggedServiceIds(self::QUEUE_MANAGER_TAG) as $id => $tags) {
$def = $container->getDefinitio... | php | {
"resource": ""
} |
q30383 | PoolsPass.setupPools | train | private function setupPools(ContainerBuilder $container)
{
$pools = $container->getParameter('gendoria_command_queue.pools');
$usedServiceIds = array();
foreach ($pools as $poolData) {
$sendServiceId = substr($poolData['send_driver'], 1);
if (in_array($sendServiceId, ... | php | {
"resource": ""
} |
q30384 | WorkerRunnerManager.addRunnerService | train | public function addRunnerService($name, $id, array $options = array())
{
if (!$this->container->has($id)) {
throw new InvalidArgumentException("Service container does not have required service registered.");
}
$this->runnerServices[$name] = array(
'id' => $id,
... | php | {
"resource": ""
} |
q30385 | WrappedStringList.compact | train | protected static function compact( array $lists, $outerSep ) {
$consolidated = [];
foreach ( $lists as $list ) {
if ( !$list instanceof WrappedStringList ) {
// Probably WrappedString or regular string,
// Not mergable as a list, but may be merged as a string
// later by WrappedString::compact.
$... | php | {
"resource": ""
} |
q30386 | RutBuilder.generate | train | public function generate(int $iterations = 1, bool $unwrapSingle = true)
{
list ($this->min, $this->max) = $this->prepareMinMax();
$this->iterations = $iterations = max(1, $iterations);
$array = $this->performGenerate($iterations);
if ($this->unique) {
$array = $this->... | php | {
"resource": ""
} |
q30387 | RutBuilder.performGenerate | train | protected function performGenerate(int $iterations)
{
switch ($this->output) {
case 'raw':
$array = $this->generateRaws($iterations, $this->min, $this->max);
break;
case 'string':
$array = $this->generateStrings($iterations, $this->min,... | php | {
"resource": ""
} |
q30388 | RutBuilder.prepareMinMax | train | protected function prepareMinMax()
{
$min = 1000000;
$max = RutHelper::COMPANY_RUT_BASE;
if (!$this->person) {
$min = $max;
$max = 100000000;
}
return [$min, $max];
} | php | {
"resource": ""
} |
q30389 | RutBuilder.generateObjects | train | protected function generateObjects(int $iterations, int $min, int $max)
{
$array = [];
for ($i = 0; $i < $iterations; ++$i) {
$array[] = RutHelper::rectify(rand($min, $max));
}
return $array;
} | php | {
"resource": ""
} |
q30390 | RutBuilder.generateRaws | train | protected function generateRaws(int $iterations, int $min, int $max)
{
$array = [];
for ($i = 0; $i < $iterations; ++$i) {
$array[] = ($rut = rand($min, $max)) . RutHelper::getVd($rut);
}
return $array;
} | php | {
"resource": ""
} |
q30391 | RutBuilder.generateStrings | train | protected function generateStrings(int $iterations, int $min, int $max)
{
$array = [];
for ($i = 0; $i < $iterations; ++$i) {
$rut = rand($min, $max);
$array[] = number_format($rut, 0, ',', '.') . '-' . RutHelper::getVd($rut);
}
return $array;
} | php | {
"resource": ""
} |
q30392 | RutBuilder.fillNonUniqueIterations | train | protected function fillNonUniqueIterations(array &$array)
{
$array = array_unique($array, SORT_REGULAR);
while ($this->iterations > ($total = count($array))) {
array_push($array, ...$this->performGenerate($this->iterations - $total));
$array = array_unique($array, SORT_REG... | php | {
"resource": ""
} |
q30393 | Dicionario.readMultValues | train | private function readMultValues(Meta $m, int $id): array
{
$data = [];
$read = new Read();
$read->exeRead(PRE . $this->entity . "_" . $m->getColumn(), "WHERE {$this->entity}_id = :id", "id={$id}");
if ($read->getResult()) {
foreach ($read->getResult() as $item)
... | php | {
"resource": ""
} |
q30394 | Dicionario.getDataFullRead | train | public function getDataFullRead(string $column = null)
{
if (!empty($column))
return (is_int($column) && isset($this->dicionario[$column]) ? $this->dicionario[$column]->getValue() : (!empty($value = $this->dicionario[$this->searchValue($column)]) ? $value->getValue() : null));
$data = n... | php | {
"resource": ""
} |
q30395 | UrlManager.generateRoute | train | protected function generateRoute(Language $language, Page $page)
{
return sprintf('_%s_%s', $language->getLanguageName(), str_replace("-", "_", $page->getPageName()));
} | php | {
"resource": ""
} |
q30396 | ClearEntityManagersListener.clearEntityManagers | train | private function clearEntityManagers()
{
foreach ($this->managerRegistry->getManagers() as /* @var $manager EntityManager */ $manager) {
if (!$manager instanceof EntityManager) {
continue;
}
$manager->clear();
if (!$manager->getConnection()->pi... | php | {
"resource": ""
} |
q30397 | HeaderBag.resolveAuth | train | protected function resolveAuth(array $parameters, array $headers)
{
isset($parameters['PHP_AUTH_USER']) ? $this->resolvePHPAuth($parameters, $headers) : $this->resolveHTTPAuth($parameters, $headers);
if (isset($headers['PHP_AUTH_USER'])) {
$headers['AUTHORIZATION'] = 'basic ' . base64_e... | php | {
"resource": ""
} |
q30398 | HeaderBag.resolveHTTPAuth | train | protected function resolveHTTPAuth(array &$parameters, array &$headers)
{
$authorizationHeader = null;
if (isset($parameters['HTTP_AUTHORIZATION'])) {
$authorizationHeader = $parameters['HTTP_AUTHORIZATION'];
} elseif (isset($parameters['REDIRECT_HTTP_AUTHORIZATION'])) {
... | php | {
"resource": ""
} |
q30399 | HeaderBag.resolveLanguages | train | protected function resolveLanguages()
{
if (!$this->get('accept_language')) {
return [];
}
$codes = $this->extractHeaders();
$languages = array();
foreach ($codes as $lang) {
if (strpos($lang, '-') !== false) {
$codes = explode('-', $... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.