_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q12100 | Element.range | train | public static function range($name, $value, array $attributes = array())
{
$node = new Node\Range();
if (!is_null($name)) {
$attributes['name'] = $name;
}
if (!is_null($value)) {
$attributes['value'] = $value;
}
return $node->render($attribu... | php | {
"resource": ""
} |
q12101 | Element.url | train | public static function url($name, $value, array $attributes = array())
{
$node = new Node\Url();
if (!is_null($name)) {
$attributes['name'] = $name;
}
if (!is_null($value)) {
$attributes['value'] = $value;
}
return $node->render($attributes)... | php | {
"resource": ""
} |
q12102 | Element.password | train | public static function password($name, $value, array $attributes = array())
{
$node = new Node\Password();
if (!is_null($name)) {
$attributes['name'] = $name;
}
if (!is_null($value)) {
$attributes['value'] = $value;
}
return $node->render($a... | php | {
"resource": ""
} |
q12103 | Element.object | train | public static function object($width, $height, $data)
{
$node = new Node\Object();
$attributes = array(
'width' => $width,
'height' => $height,
'data' => $data
);
return $node->render($attributes);
} | php | {
"resource": ""
} |
q12104 | Element.audio | train | public static function audio($src, array $attrs = array(), $error = null)
{
$node = new Node\Audio($src, $error);
return $node->render($attrs);
} | php | {
"resource": ""
} |
q12105 | Element.video | train | public static function video($src, array $attrs = array(), $error = null)
{
$node = new Node\Video($src, $error);
return $node->render($attrs);
} | php | {
"resource": ""
} |
q12106 | DocumentEntity.publicValue | train | public function publicValue(): array
{
$public = parent::publicValue();
array_walk_recursive($public, function (&$value) {
if ($value instanceof ObjectID) {
$value = (string)$value;
}
});
return $public;
} | php | {
"resource": ""
} |
q12107 | TaskCommonTrait.runSilentCommand | train | protected function runSilentCommand(TaskInterface $task)
{
return $task->printOutput(false)
// This is weird as you would expect this to give you more
// information, but it suppresses the exit code from display.
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOS... | php | {
"resource": ""
} |
q12108 | Select.createDefaultOptionNodes | train | private function createDefaultOptionNodes()
{
$nodes = array();
foreach ($this->defaults as $key => $value) {
// Only scalars are allowed, the rest is ignored
if (is_scalar($value)) {
array_push($nodes, $this->createOptionNode($key, $value));
}
... | php | {
"resource": ""
} |
q12109 | Select.isActiveNode | train | private function isActiveNode($value)
{
if (is_array($this->active)) {
$actives = array_values($this->active);
return in_array($value, $actives);
} else {
// Select all if asterik is provided
if ($this->active === '*') {
return true;
... | php | {
"resource": ""
} |
q12110 | Select.createOptionNode | train | private function createOptionNode($value, $text)
{
$option = new NodeElement();
$option->openTag('option')
->addAttribute('value', $value);
// Mark as selected on demand
if ($this->isActiveNode($value)) {
$option->addProperty('selected');
}
... | php | {
"resource": ""
} |
q12111 | Select.createOptgroupNode | train | private function createOptgroupNode($label, array $list)
{
$optgroup = new NodeElement();
$optgroup->openTag('optgroup')
->addAttribute('label', $label)
->finalize();
foreach ($this->getOptions($list) as $option) {
$optgroup->appendChild($option... | php | {
"resource": ""
} |
q12112 | Select.getOptions | train | private function getOptions(array $list)
{
// To be returned
$elements = array();
foreach ($list as $value => $text) {
array_push($elements, $this->createOptionNode($value, $text));
}
return $elements;
} | php | {
"resource": ""
} |
q12113 | DataSource.formatIndex | train | protected function formatIndex($name)
{
if (\is_string($name)) {
$exp = explode('.', $name);
if (0 < \count($exp)) {
$name = $exp[\count($exp) - 1];
}
}
return $name;
} | php | {
"resource": ""
} |
q12114 | DataSource.getDataField | train | protected function getDataField($dataRow, $name, \Closure $emptyData = null)
{
$value = null !== $name && '' !== $name
? $this->propertyAccessor->getValue($dataRow, $name)
: null;
if (null === $value && $emptyData instanceof \Closure) {
$value = $emptyData($dataR... | php | {
"resource": ""
} |
q12115 | DataSource.overrideCellOptions | train | protected function overrideCellOptions(BlockInterface $column, $formatter, $data, array $options)
{
$config = $column->getConfig();
if ($config->hasOption('override_options')
&& ($override = $config->getOption('override_options')) instanceof \Closure) {
/* @var \Closure ... | php | {
"resource": ""
} |
q12116 | DataSource.doPreGetData | train | protected function doPreGetData()
{
foreach ($this->dataTransformers as $dataTransformer) {
if ($dataTransformer instanceof PreGetDataTransformerInterface) {
$dataTransformer->preGetData($this->config);
}
}
} | php | {
"resource": ""
} |
q12117 | DataSource.doPostGetData | train | protected function doPostGetData()
{
foreach ($this->dataTransformers as $dataTransformer) {
if ($dataTransformer instanceof PostGetDataTransformerInterface) {
$dataTransformer->postGetData($this->config);
}
}
} | php | {
"resource": ""
} |
q12118 | DefaultEncoderRegistrant.registerDefaultEncoders | train | public function registerDefaultEncoders(EncoderRegistry $encoders): EncoderRegistry
{
$encoders->registerDefaultObjectEncoder(new ObjectEncoder($encoders, $this->propertyNameFormatter));
$encoders->registerDefaultScalarEncoder(new ScalarEncoder());
$encoders->registerEncoder('array', new Arr... | php | {
"resource": ""
} |
q12119 | DrupalProjectType.exportDrupalConfig | train | public function exportDrupalConfig()
{
$version = $this->getProjectVersion();
if ($version >= 8) {
$this->runDrushCommand('cex');
$this->saveDrupalUuid();
}
return $this;
} | php | {
"resource": ""
} |
q12120 | DrupalProjectType.importDrupalConfig | train | public function importDrupalConfig($reimport_attempts = 1, $localhost = false)
{
if ($this->getProjectVersion() >= 8) {
try {
$drush = (new DrushCommand(null, $localhost))
->command('cr')
->command('cim');
$this->runDrushCo... | php | {
"resource": ""
} |
q12121 | DrupalProjectType.optionForm | train | public function optionForm()
{
$fields = [];
$default = $this->defaultInstallOptions();
$fields[] = (new BooleanField('site', 'Setup Drupal site options?'))
->setDefault(false)
->setSubform(function ($subform, $value) use ($default) {
if ($value === t... | php | {
"resource": ""
} |
q12122 | DrupalProjectType.setupProject | train | public function setupProject()
{
$this->taskWriteToFile(ProjectX::projectRoot() . '/.gitignore')
->text($this->loadTemplateContents('.gitignore.txt'))
->place('PROJECT_ROOT', $this->getInstallRoot(true))
->run();
return $this;
} | php | {
"resource": ""
} |
q12123 | DrupalProjectType.setupProjectComposer | train | public function setupProjectComposer()
{
$this->mergeProjectComposerTemplate();
$install_root = substr(static::installRoot(), 1);
$version = $this->getProjectVersion();
$this->composer
->setType('project')
->setPreferStable(true)
->setMinimumStabi... | php | {
"resource": ""
} |
q12124 | DrupalProjectType.packageDrupalBuild | train | public function packageDrupalBuild($build_root)
{
$project_root = ProjectX::projectRoot();
$build_install = $build_root . static::installRoot();
$install_path = $this->getInstallPath();
$stack = $this->taskFilesystemStack();
$static_files = [
"{$project_root}/sal... | php | {
"resource": ""
} |
q12125 | DrupalProjectType.setupDrush | train | public function setupDrush($exclude_remote = false)
{
$project_root = ProjectX::projectRoot();
$this->taskFilesystemStack()
->mirror($this->getTemplateFilePath('drush'), "$project_root/drush")
->copy($this->getTemplateFilePath('drush.wrapper'), "$project_root/drush.wrapper")... | php | {
"resource": ""
} |
q12126 | DrupalProjectType.setupDrushAlias | train | public function setupDrushAlias($exclude_remote = false)
{
$project_root = ProjectX::projectRoot();
if (!file_exists("$project_root/drush/site-aliases")) {
$continue = $this->askConfirmQuestion(
"Drush aliases haven't been setup for this project.\n"
. "\n... | php | {
"resource": ""
} |
q12127 | DrupalProjectType.setupDrushLocalAlias | train | public function setupDrushLocalAlias($alias_name = null)
{
$config = ProjectX::getProjectConfig();
$alias_name = isset($alias_name)
? Utiltiy::machineName($alias_name)
: ProjectX::getProjectMachineName();
$alias_content = $this->drushAliasFileContent(
$a... | php | {
"resource": ""
} |
q12128 | DrupalProjectType.setupDrushRemoteAliases | train | public function setupDrushRemoteAliases()
{
$project_root = ProjectX::projectRoot();
$drush_aliases_dir = "$project_root/drush/site-aliases";
foreach (ProjectX::getRemoteEnvironments() as $realm => $environment) {
$file_task = $this
->taskWriteToFile("$drush_alia... | php | {
"resource": ""
} |
q12129 | DrupalProjectType.createDrupalLoginLink | train | public function createDrupalLoginLink($user = null, $path = null, $localhost = false)
{
$arg = [];
if (isset($user)) {
$arg[] = $user;
}
if (isset($path)) {
$arg[] = $path;
}
$args = implode(' ', $arg);
$drush = (new DrushCommand(null,... | php | {
"resource": ""
} |
q12130 | DrupalProjectType.setupDrupalFilesystem | train | public function setupDrupalFilesystem()
{
$this->taskFilesystemStack()
->chmod($this->sitesPath, 0775, 0000, true)
->mkdir("{$this->sitesPath}/default/files", 0775, true)
->run();
if ($this->getProjectVersion() >= 8) {
$install_path = $this->getInstal... | php | {
"resource": ""
} |
q12131 | DrupalProjectType.setupDrupalSettings | train | public function setupDrupalSettings()
{
$this->_copy(
"{$this->sitesPath}/default/default.settings.php",
$this->settingFile
);
$install_root = dirname($this->getQualifiedInstallRoot());
if ($this->getProjectVersion() >= 8) {
$this->taskWriteToFile... | php | {
"resource": ""
} |
q12132 | DrupalProjectType.setupDrupalLocalSettings | train | public function setupDrupalLocalSettings()
{
$version = $this->getProjectVersion();
$local_settings = $this
->templateManager()
->loadTemplate("{$version}/settings.local.txt");
$this->_remove($this->settingLocalFile);
if ($version >= 8) {
$setti... | php | {
"resource": ""
} |
q12133 | DrupalProjectType.setupDrupalInstall | train | public function setupDrupalInstall($localhost = false)
{
$this->say('Waiting on Drupal database to become available...');
$database = $this->getDatabaseInfo();
$engine = $this->getEngineInstance();
$install_path = $this->getInstallPath();
if ($engine instanceof DockerEngin... | php | {
"resource": ""
} |
q12134 | DrupalProjectType.removeGitSubmodulesInVendor | train | public function removeGitSubmodulesInVendor($base_path = null)
{
$base_path = isset($base_path) && file_exists($base_path)
? $base_path
: ProjectX::projectRoot();
$composer = $this->getComposer();
$composer_config = $composer->getConfig();
$vendor_dir = isse... | php | {
"resource": ""
} |
q12135 | DrupalProjectType.getValidComposerInstallPaths | train | public function getValidComposerInstallPaths($base_path = null)
{
$filepaths = [];
/** @var ComposerConfig $composer */
$composer = $this->getComposer();
$composer_extra = $composer->getExtra();
$base_path = isset($base_path) && file_exists($base_path)
? $base_p... | php | {
"resource": ""
} |
q12136 | DrupalProjectType.runDrushCommand | train | public function runDrushCommand($command, $quiet = false, $localhost = false)
{
if ($command instanceof CommandBuilder) {
$drush = $command;
} else {
$drush = new DrushCommand(null, $localhost);
foreach (explode('&&', $command) as $string) {
$drush... | php | {
"resource": ""
} |
q12137 | DrupalProjectType.setDrupalUuid | train | public function setDrupalUuid($localhost = false)
{
if ($this->getProjectVersion() >= 8) {
$build_info = $this->getProjectOptionByKey('build_info');
if ($build_info !== false
&& isset($build_info['uuid'])
&& !empty($build_info['uuid'])) {
... | php | {
"resource": ""
} |
q12138 | DrupalProjectType.refreshDatabaseSettings | train | protected function refreshDatabaseSettings()
{
/** @var Database $database */
$database = $this->getDatabaseInfo();
$settings = file_get_contents($this->settingLocalFile);
// Replace database properties based on database info.
foreach ($database->asArray() as $property => $v... | php | {
"resource": ""
} |
q12139 | DrupalProjectType.setupDatabaseFromRestore | train | protected function setupDatabaseFromRestore(
$method = null,
$localhost = false
) {
/** @var EngineType $engine */
$engine = $this->getEngineInstance();
if ($engine instanceof DockerEngineType) {
$options = $this->databaseRestoreOptions();
if (!isset... | php | {
"resource": ""
} |
q12140 | DrupalProjectType.databaseRestoreOptions | train | protected function databaseRestoreOptions()
{
$options = [];
if ($this->getProjectVersion() >= 8 && $this->hasDrupalConfig()) {
$options[] = 'site-config';
}
$options[] = 'database-import';
/** @var DrupalPlatformRestoreInterface $platform */
$platform =... | php | {
"resource": ""
} |
q12141 | DrupalProjectType.hasDatabaseInfoChanged | train | protected function hasDatabaseInfoChanged()
{
$settings_uri = $this->settingLocalFile;
if (file_exists($settings_uri)) {
$settings = file_get_contents($settings_uri);
$match_status = preg_match_all("/\'(database|username|password|host|port|driver)\'\s=>\s\'(.+)\'\,?/", $setti... | php | {
"resource": ""
} |
q12142 | DrupalProjectType.getDrupalUuid | train | protected function getDrupalUuid()
{
$uuid = null;
$version = $this->getProjectVersion();
if ($version >= 8) {
$result = $this->runDrushCommand('cget system.site uuid', true);
if ($result->getExitCode() === ResultData::EXITCODE_OK) {
$message = $resu... | php | {
"resource": ""
} |
q12143 | DrupalProjectType.saveDrupalUuid | train | protected function saveDrupalUuid()
{
$config = ProjectX::getProjectConfig();
$options[static::getTypeId()] = [
'build_info' => [
'uuid' => $this->getDrupalUuid()
]
];
$config
->setOptions($options)
->save(ProjectX::get... | php | {
"resource": ""
} |
q12144 | DrupalProjectType.drushInstallCommonStack | train | protected function drushInstallCommonStack(
$executable,
$drupal_root,
DatabaseInterface $database
) {
$options = $this->getInstallOptions();
$db_user = $database->getUser();
$db_port = $database->getPort();
$db_pass = $database->getPassword();
$db_na... | php | {
"resource": ""
} |
q12145 | DrupalProjectType.drushAliasFileContent | train | protected function drushAliasFileContent($name, $uri, $root, array $options = [], $include_opentag = true)
{
$name = Utility::machineName($name);
$content = $include_opentag ? "<?php\n\n" : '';
$content .= "\$aliases['$name'] = [";
$content .= "\n\t'uri' => '$uri',";
$conte... | php | {
"resource": ""
} |
q12146 | DrupalProjectType.setupDrupalSettingsLocalInclude | train | protected function setupDrupalSettingsLocalInclude()
{
$this->taskWriteToFile($this->settingFile)
->append()
->appendUnlessMatches(
'/if.+\/settings\.local\.php.+{\n.+\n\}/',
$this->drupalSettingsLocalInclude()
)
->run();
... | php | {
"resource": ""
} |
q12147 | UploadChain.upload | train | public function upload($id, array $files)
{
foreach ($this->uploaders as $uploader) {
if (!$uploader->upload($id, $files)) {
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q12148 | PhpService.getDockerfileVariables | train | protected function getDockerfileVariables()
{
// Merge service OS packages definition.
if ($os_packages = $this->getInfoProperty('packages')) {
$this->mergeConfigVariable('PACKAGE_INSTALL', $os_packages);
}
// Merge service PHP pecl packages definition.
if ($pecl... | php | {
"resource": ""
} |
q12149 | PhpService.processDockerfileVariables | train | protected function processDockerfileVariables()
{
$variables = [];
$variables['PHP_VERSION'] = $this->getVersion();
foreach ($this->configs as $key => $values) {
if (!in_array($key, static::DOCKER_VARIABLES)) {
continue;
}
if ($key === 'P... | php | {
"resource": ""
} |
q12150 | PhpService.formatVariables | train | protected function formatVariables($key, array $values)
{
switch ($key) {
case 'PHP_PECL':
return $this->formatPeclPackages($values);
case 'PHP_COMMANDS':
return $this->formatRunCommand($values);
case 'PHP_EXT_CONFIG':
case 'PHP... | php | {
"resource": ""
} |
q12151 | PhpService.formatPeclPackages | train | protected function formatPeclPackages(array $values)
{
$packages = [];
foreach ($values as $package) {
list($name, $version) = strpos($package, ':') !== false
? explode(':', $package)
: [$package, null];
if ($name === 'xdebug' && !isset($vers... | php | {
"resource": ""
} |
q12152 | Native.generateLocationAuth | train | protected function generateLocationAuth(string $authTicket, float $latitude, float $longitude, float $altitude = 0.0)
{
$seed = hexdec(xxhash32($authTicket, 0x1B845238));
return (int)hexdec(xxhash32($this->getLocationBytes($latitude, $longitude, $altitude), (int)$seed));
} | php | {
"resource": ""
} |
q12153 | Native.generateLocation | train | protected function generateLocation(float $latitude, float $longitude, float $altitude = 0.0) : int
{
return (int)hexdec(xxhash32($this->getLocationBytes($latitude, $longitude, $altitude), 0x1B845238));
} | php | {
"resource": ""
} |
q12154 | Native.generateRequestHash | train | protected function generateRequestHash(string $authTicket, string $request) : int
{
$seed = (unpack("J", pack("H*", xxhash64($authTicket, 0x1B845238))))[1];
return (unpack("J", pack("H*", xxhash64($request, $seed))))[1];
} | php | {
"resource": ""
} |
q12155 | Native.getLocationBytes | train | protected function getLocationBytes(float $latitude, float $longitude, float $altitude) : string
{
return Hex::d2h($latitude) . Hex::d2h($longitude) . Hex::d2h($altitude);
} | php | {
"resource": ""
} |
q12156 | SqlConfigServiceFactory.build | train | public static function build($pdo, $table)
{
$configMapper = new ConfigMapper(new Serializer(), $pdo, $table);
return new SqlConfigService($configMapper, new ArrayConfig());
} | php | {
"resource": ""
} |
q12157 | Action.destroy | train | public function destroy($id)
{
$this->guardAgainstMissingParent('destroy');
$this->shopify->delete($this->path($id));
} | php | {
"resource": ""
} |
q12158 | Action.requiresParent | train | protected function requiresParent(string $methodName)
{
if (in_array('*', $this->requiresParent)) {
return true;
}
return in_array($methodName, $this->requiresParent);
} | php | {
"resource": ""
} |
q12159 | GitAuthorExtractorTrait.getGitRepositoryFor | train | protected function getGitRepositoryFor($path)
{
$git = new GitRepository($this->determineGitRoot($path));
if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
$git->getConfig()->setLogger(
new ConsoleLogger($this->output)
);
}
... | php | {
"resource": ""
} |
q12160 | GitAuthorExtractorTrait.getAllFilesFromGit | train | private function getAllFilesFromGit($git)
{
$gitDir = $git->getRepositoryPath();
// Sadly no command in our git library for this.
$arguments = [
$git->getConfig()->getGitExecutablePath(),
'ls-tree',
'HEAD',
'-r',
'--full-name',
... | php | {
"resource": ""
} |
q12161 | GitAuthorExtractorTrait.getFilePaths | train | public function getFilePaths()
{
$files = [];
foreach ($this->config->getIncludedPaths() as $path) {
$files[] = $this->getAllFilesFromGit($this->getGitRepositoryFor($path));
}
return array_merge(...$files);
} | php | {
"resource": ""
} |
q12162 | GitAuthorExtractorTrait.determineGitRoot | train | private function determineGitRoot($path)
{
// @codingStandardsIgnoreStart
while (\strlen($path) > 1) {
// @codingStandardsIgnoreEnd
if (\is_dir($path . DIRECTORY_SEPARATOR . '.git')) {
return $path;
}
$path = \dirname($path);
}... | php | {
"resource": ""
} |
q12163 | GitAuthorExtractorTrait.getCurrentUserInfo | train | protected function getCurrentUserInfo($git)
{
// Sadly no command in our git library for this.
$arguments = [
$git->getConfig()->getGitExecutablePath(),
'config',
'--get-regexp',
'user.[name|email]'
];
$process = new Process($this->pre... | php | {
"resource": ""
} |
q12164 | GitAuthorExtractorTrait.runCustomGit | train | private function runCustomGit(array $arguments, GitRepository $git)
{
$process = new Process($this->prepareProcessArguments($arguments), $git->getRepositoryPath());
$git->getConfig()->getLogger()->debug(
\sprintf('[git-php] exec [%s] %s', $process->getWorkingDirectory(), $process->getCom... | php | {
"resource": ""
} |
q12165 | GitAuthorExtractorTrait.prepareProcessArguments | train | protected function prepareProcessArguments(array $arguments)
{
$reflection = new \ReflectionClass(ProcessUtils::class);
if (!$reflection->hasMethod('escapeArgument')) {
return $arguments;
}
return \implode(' ', \array_map([ProcessUtils::class, 'escapeArgument'], $argume... | php | {
"resource": ""
} |
q12166 | Addresses.load | train | public static function load(string $filename = 'my-addresses.php'): array
{
$file = (new static())->getDirectoryPaths()
->map(function ($path) use ($filename) {
return $path . $filename;
})
->first(function ($file) {
return file_exists($fil... | php | {
"resource": ""
} |
q12167 | InteractiveMessage.setReplyMarkup | train | public function setReplyMarkup(\KeythKatz\TelegramBotCore\Type\InlineKeyboardMarkup $keyboard): void
{
$this->baseMethod->setReplyMarkup($keyboard);
} | php | {
"resource": ""
} |
q12168 | InteractiveMessage.send | train | public function send(): void
{
$sentMessage = $this->baseMethod->send();
$this->messageId = $sentMessage->getMessageId();
$this->chatId = $sentMessage->getChat()->getId();
$this->saveState();
} | php | {
"resource": ""
} |
q12169 | ListViewMaker.render | train | public function render()
{
$data = $this->createData();
$table = $this->createTable($data, $this->options[self::LISTVIEW_PARAM_TABLE_CLASS]);
return $table->render();
} | php | {
"resource": ""
} |
q12170 | ListViewMaker.createData | train | private function createData()
{
$output = array();
$hasTranslator = $this->translator instanceof TranslatorInterface;
foreach ($this->options[self::LISTVIEW_PARAM_COLUMNS] as $configuration) {
// Do processing only if column available
if (isset($this->data[$configura... | php | {
"resource": ""
} |
q12171 | ListViewMaker.createRow | train | private function createRow($key, $value)
{
$tr = new NodeElement();
$tr->openTag('tr');
$first = new NodeElement();
$first->openTag('td')
->finalize()
->setText($key)
->closeTag();
$second = new NodeElement();
$second->openT... | php | {
"resource": ""
} |
q12172 | Builder.build | train | private function build(): void
{
$prefix = "<?xml version='1.0' encoding='UTF-8'?>" . $this->glue() . "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>";
$suffix = '</feed>';
$xml = collect($this->filters)->map(function ($items) {
retur... | php | {
"resource": ""
} |
q12173 | Builder.buildEntry | train | private function buildEntry(Filter $filter): string
{
$entry = collect($filter->toArray())
->map(function ($value, $key): string {
return $this->buildProperty($value, $key);
})
->implode($this->glue());
return collect(['<entry>', $entry, '</entry>... | php | {
"resource": ""
} |
q12174 | Builder.buildProperty | train | private function buildProperty($value, $key): string
{
if (collect(['from', 'to'])->contains($key)) {
$value = $this->implode($value);
}
return vsprintf("<apps:property name='%s' value='%s'/>", [
$key,
htmlentities($this->implode($value)),
]);
... | php | {
"resource": ""
} |
q12175 | Builder.implode | train | private function implode($value, $separator = '|'): string
{
if (is_string($value)) {
return $value;
}
if (is_array($value) && count($value) === 1) {
return reset($value);
}
return sprintf('(%s)', collect($value)->implode($separator));
} | php | {
"resource": ""
} |
q12176 | ConfigurationAdminController.clearCacheAction | train | public function clearCacheAction() {
$this->getConfigurationManager()->clearCache();
$this->addFlash('sonata_flash_success', 'Cache clear successfully');
return new \Symfony\Component\HttpFoundation\RedirectResponse($this->admin->generateUrl('list'));
} | php | {
"resource": ""
} |
q12177 | EmailObfuscatorRequestProcessor.encode | train | protected function encode($originalString)
{
$encodedString = '';
$nowCodeString = '';
$originalLength = strlen($originalString);
for ($i = 0; $i < $originalLength; $i++) {
$encodeMode = ($i % 2 == 0) ? 1 : 2; // Switch encoding odd/even
switch ($encodeMode) {... | php | {
"resource": ""
} |
q12178 | RelationBuilder.build | train | public function build(array $data)
{
$relations = array(
self::TREE_PARAM_ITEMS => array(),
self::TREE_PARAM_PARENTS => array()
);
foreach ($data as $row) {
$relations[self::TREE_PARAM_ITEMS][$row[self::TREE_PARAM_ID]] = $row;
$relations[self:... | php | {
"resource": ""
} |
q12179 | Helper.faker | train | final protected function faker(string $locale = 'en_US'): Generator
{
static $fakers = [];
if (!\array_key_exists($locale, $fakers)) {
$faker = Factory::create($locale);
$faker->seed(9001);
$fakers[$locale] = $faker;
}
return $fakers[$locale];
... | php | {
"resource": ""
} |
q12180 | Helper.assertClassesAreAbstractOrFinal | train | final protected function assertClassesAreAbstractOrFinal(string $directory, array $excludeClassNames = []): void
{
$this->assertClassyConstructsSatisfySpecification(
static function (string $className): bool {
$reflection = new \ReflectionClass($className);
retur... | php | {
"resource": ""
} |
q12181 | Helper.assertClassyConstructsSatisfySpecification | train | final protected function assertClassyConstructsSatisfySpecification(callable $specification, string $directory, array $excludeClassyNames = [], string $message = ''): void
{
if (!\is_dir($directory)) {
throw Exception\NonExistentDirectory::fromDirectory($directory);
}
\array_wal... | php | {
"resource": ""
} |
q12182 | Helper.assertClassExists | train | final protected function assertClassExists(string $className): void
{
self::assertTrue(\class_exists($className), \sprintf(
'Failed asserting that a class "%s" exists.',
$className
));
} | php | {
"resource": ""
} |
q12183 | Helper.assertClassExtends | train | final protected function assertClassExtends(string $parentClassName, string $className): void
{
$this->assertClassExists($parentClassName);
$this->assertClassExists($className);
$reflection = new \ReflectionClass($className);
self::assertTrue($reflection->isSubclassOf($parentClassN... | php | {
"resource": ""
} |
q12184 | Helper.assertClassImplementsInterface | train | final protected function assertClassImplementsInterface(string $interfaceName, string $className): void
{
$this->assertInterfaceExists($interfaceName);
$this->assertClassExists($className);
$reflection = new \ReflectionClass($className);
self::assertTrue($reflection->implementsInte... | php | {
"resource": ""
} |
q12185 | Helper.assertClassIsAbstract | train | final protected function assertClassIsAbstract(string $className): void
{
$this->assertClassExists($className);
$reflection = new \ReflectionClass($className);
self::assertTrue($reflection->isAbstract(), \sprintf(
'Failed asserting that class "%s" is abstract.',
$cl... | php | {
"resource": ""
} |
q12186 | Helper.assertClassIsFinal | train | final protected function assertClassIsFinal(string $className): void
{
$this->assertClassExists($className);
$reflection = new \ReflectionClass($className);
self::assertTrue($reflection->isFinal(), \sprintf(
'Failed asserting that class "%s" is final.',
$className
... | php | {
"resource": ""
} |
q12187 | Helper.assertClassSatisfiesSpecification | train | final protected function assertClassSatisfiesSpecification(callable $specification, string $className, string $message = ''): void
{
$this->assertClassExists($className);
self::assertTrue($specification($className), \sprintf(
'' !== $message ? $message : 'Failed asserting that class "%s... | php | {
"resource": ""
} |
q12188 | Helper.assertClassUsesTrait | train | final protected function assertClassUsesTrait(string $traitName, string $className): void
{
$this->assertTraitExists($traitName);
$this->assertClassExists($className);
self::assertContains($traitName, \class_uses($className), \sprintf(
'Failed asserting that class "%s" uses trai... | php | {
"resource": ""
} |
q12189 | Helper.assertInterfaceExists | train | final protected function assertInterfaceExists(string $interfaceName): void
{
self::assertTrue(\interface_exists($interfaceName), \sprintf(
'Failed asserting that an interface "%s" exists.',
$interfaceName
));
} | php | {
"resource": ""
} |
q12190 | Helper.assertInterfaceExtends | train | final protected function assertInterfaceExtends(string $parentInterfaceName, string $interfaceName): void
{
$this->assertInterfaceExists($parentInterfaceName);
$this->assertInterfaceExists($interfaceName);
$reflection = new \ReflectionClass($interfaceName);
self::assertTrue($reflec... | php | {
"resource": ""
} |
q12191 | Helper.assertInterfaceSatisfiesSpecification | train | final protected function assertInterfaceSatisfiesSpecification(callable $specification, string $interfaceName, string $message = ''): void
{
$this->assertInterfaceExists($interfaceName);
self::assertTrue($specification($interfaceName), \sprintf(
'' !== $message ? $message : 'Failed asse... | php | {
"resource": ""
} |
q12192 | Helper.assertTraitExists | train | final protected function assertTraitExists(string $traitName): void
{
self::assertTrue(\trait_exists($traitName), \sprintf(
'Failed asserting that a trait "%s" exists.',
$traitName
));
} | php | {
"resource": ""
} |
q12193 | Helper.assertTraitSatisfiesSpecification | train | final protected function assertTraitSatisfiesSpecification(callable $specification, string $traitName, string $message = ''): void
{
$this->assertTraitExists($traitName);
self::assertTrue($specification($traitName), \sprintf(
'' !== $message ? $message : 'Failed asserting that trait "%s... | php | {
"resource": ""
} |
q12194 | Category.get | train | public static function get(Bookboon $bookboon, string $categoryId, array $bookTypes = ['pdf']) : BookboonResponse
{
$bResponse = $bookboon->rawRequest("/categories/$categoryId", ['bookType' => join(',', $bookTypes)]);
$bResponse->setEntityStore(
new EntityStore(
[
... | php | {
"resource": ""
} |
q12195 | Category.getTree | train | public static function getTree(
Bookboon $bookboon,
array $blacklistedCategoryIds = [],
int $depth = 2
) : BookboonResponse {
$bResponse = $bookboon->rawRequest('/categories', ['depth' => $depth]);
$categories = $bResponse->getReturnArray();
if (count($blacklistedCa... | php | {
"resource": ""
} |
q12196 | Headers.set | train | public function set(string $header, string $value) : void
{
$this->headers[$header] = $value;
} | php | {
"resource": ""
} |
q12197 | Headers.getAll | train | public function getAll() : array
{
$headers = [];
foreach ($this->headers as $h => $v) {
$headers[] = $h.': '.$v;
}
return $headers;
} | php | {
"resource": ""
} |
q12198 | Headers.getRemoteAddress | train | private function getRemoteAddress() : ?string
{
$hostname = null;
if (isset($_SERVER['REMOTE_ADDR'])) {
$hostname = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
if (false === $hostname) {
$hostname = null;
}
}
if (fun... | php | {
"resource": ""
} |
q12199 | CDatabaseBasic.loadHistory | train | public function loadHistory()
{
$key = $this->options['session_key'];
if (isset($_SESSION['CDatabase'])) {
self::$numQueries = $_SESSION[$key]['numQueries'];
self::$queries = $_SESSION[$key]['queries'];
self::$params = $_SESSION[$key]['params'];
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.