_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q237500 | Filesystem.saveConfig | train | public function saveConfig($group, $environment = '')
{
// Path do arquivo
$path = config_path();
// Itens
$items = config($group, []);
// Nome do arquivo
$file = (! $environment || ($environment == 'production'))
? "{$path}/{$group}.php"
: "... | php | {
"resource": ""
} |
q237501 | Relation.select | train | public function select($table)
{
$props = call_user_func(array($this->model_to, 'properties'));
$i = 0;
$properties = array();
foreach ($props as $pk => $pv)
{
$properties[] = array($table.'.'.$pk, $table.'_c'.$i);
$i++;
}
return $properties;
} | php | {
"resource": ""
} |
q237502 | BaseConfigsBuilder.includeConfigFile | train | public static function includeConfigFile($filename, $application = null)
{
if (empty($application)) {
$application = Yii::$app;
}
$appKey = UniApplication::appKey($application);
if (!isset(self::$_configFiles[$appKey][$filename])) {
if (is_file($filename)) {
... | php | {
"resource": ""
} |
q237503 | BaseConfigsBuilder.cleanConfigFileCache | train | public static function cleanConfigFileCache($application = null)
{
if (empty($application)) {
$application = Yii::$app;
}
$appKey = UniApplication::appKey($application);
static::$_configFiles[$appKey] = [];
} | php | {
"resource": ""
} |
q237504 | Logger.write | train | protected function write($level, $msg)
{
$time = date('Y-m-d H:i:s', time());
$msg = "[" . $time . "][" . static::getLevelName($level) . "] " . $msg . PHP_EOL;
if($this->debugOutput === true){
echo $msg;
}
if (static::$silent) {
return false;
... | php | {
"resource": ""
} |
q237505 | Logger.getLevelName | train | protected static function getLevelName($value)
{
$map = array_flip((new \ReflectionClass(self::class))->getConstants());
return (array_key_exists($value, $map) ? $map[$value] : null);
} | php | {
"resource": ""
} |
q237506 | Logger.getLevelValue | train | public static function getLevelValue($name)
{
$name = strtoupper($name);
$map = (new \ReflectionClass(self::class))->getConstants();
return (isset($map[$name]))? $map[$name] : null;
} | php | {
"resource": ""
} |
q237507 | BaseValidator.error | train | protected function error( $messageKey, $value = null ) {
//was a global message set? let's use the global key then
if( key_exists( self::GLOBAL_MESSAGE_KEY, $this->templates ) )
$messageKey = self::GLOBAL_MESSAGE_KEY;
//invalide message key
if( !key_exists( $me... | php | {
"resource": ""
} |
q237508 | BaseValidator.updateMessageTemplate | train | private function updateMessageTemplate( $template, $key ) {
//invalide message key
if( !key_exists( $messageKey, $this->templates ) && $key != self::DEFAULT_KEY )
throw new Exception\MessageTemplateDoesNotExist( "A message template does not exist for key $messageKey" );
$th... | php | {
"resource": ""
} |
q237509 | SimpleAtomFieldRule.getNodeContent | train | private function getNodeContent(\DOMNode $node)
{
$type = $node->attributes->getNamedItem('type');
if ($type && strtolower($type->nodeValue) == 'xhtml') {
$result = '';
foreach ($node->childNodes as $childNode) {
$result .= $node->ownerDocument->save($childNod... | php | {
"resource": ""
} |
q237510 | Arr.getInt | train | public static function getInt(array $array, $key, int $default = 0) : int
{
$key = (string) $key;
if ($array[$key] ?? 0) {
return (int) $array[$key];
}
return $default;
} | php | {
"resource": ""
} |
q237511 | Arr.getFloat | train | public static function getFloat(array $array, $key, float $default = 0.0) : float
{
$key = (string) $key;
if ($array[$key] ?? 0) {
return (float) $array[$key];
}
return $default;
} | php | {
"resource": ""
} |
q237512 | Arr.getString | train | public static function getString(array $array, $key, string $default = '') : string
{
$key = (string) $key;
if ($array[$key] ?? 0) {
return (string) $array[$key];
}
return $default;
} | php | {
"resource": ""
} |
q237513 | Arr.getBool | train | public static function getBool(array $array, $key, bool $default = false) : bool
{
$key = (string) $key;
if ($array[$key] ?? 0) {
return (bool) $array[$key];
}
return $default;
} | php | {
"resource": ""
} |
q237514 | FunctionsTrait.swapArgs | train | protected static function swapArgs(&$optional, &$swap, $default = null, $swap_required = true)
{
$is_swapped = false;
if (empty($swap) && !empty($optional)) {
$swap = $optional;
$optional = $default;
$is_swapped = true;
}
if ($swap_required... | php | {
"resource": ""
} |
q237515 | FunctionsTrait.swapCallable | train | protected static function swapCallable(&$optional, &$callable, $default = null, $callable_required = true)
{
$is_swapped = false;
if (is_callable($optional)) {
$callable = $optional;
$optional = $default;
$is_swapped = true;
}
if ($callable_requir... | php | {
"resource": ""
} |
q237516 | FunctionsTrait.throwOnInvalidArgument | train | protected static function throwOnInvalidArgument($arg, $type)
{
$args = func_get_args();
$arg = array_shift($args);
$arg_type = gettype($arg);
$found = false;
foreach($args as $type) {
if ((in_array($type, self::$native_php_types) && $arg_type ==... | php | {
"resource": ""
} |
q237517 | Url.parse | train | private function parse()
{
$this->parameters = [];
$this->pathSegments = [];
$parsedUrl = parse_url($this->returnValue);
foreach ($parsedUrl as $key => $value) {
if ($key == 'query') {
parse_str($value, $this->parameters);
} elseif (... | php | {
"resource": ""
} |
q237518 | Url.compareTo | train | public function compareTo($url, $caseSensitive = true, $includeQuery = false, $ignoreSpecialChars = false)
{
/* @var $urlObj Url */
$urlObj = $url instanceof Url ? $url : self::create($url)->decodePath();
/* @var $urlObj2 Url */
$urlObj2 = clone $this;
$urlObj2->decodePath()... | php | {
"resource": ""
} |
q237519 | Url.fromObject | train | function fromObject($value)
{
$this->clear();
$this->orignalValue = $this->returnValue = (string) (method_exists($value, '__toString') ? $value : null);
return $this->parse();
} | php | {
"resource": ""
} |
q237520 | Url.fromString | train | function fromString($value)
{
$this->clear();
$this->orignalValue = $this->returnValue = (string) $value;
return $this->parse();
} | php | {
"resource": ""
} |
q237521 | Url.fromResource | train | function fromResource($value)
{
$this->clear();
$this->orignalValue = $this->returnValue = stream_get_contents($value);
return $this->parse();
} | php | {
"resource": ""
} |
q237522 | Url.clear | train | protected function clear()
{
$this->scheme = null;
$this->host = null;
$this->port = null;
$this->user = null;
$this->pass = null;
$this->pathSegments = [];
$this->parameters = [];
$this->fragment = null;
... | php | {
"resource": ""
} |
q237523 | Url.offsetGet | train | public function offsetGet($offset)
{
return isset($this->pathSegments[$offset]) ? $this->pathSegments[$offset] : null;
} | php | {
"resource": ""
} |
q237524 | Url.current | train | public function current($includeQuery = true)
{
$url = "";
if (!$this->serverVars && php_sapi_name() == 'cli') {
$url = "cli";
} else {
$url .= $this->currentScheme().$this->currentHost();
$port = $this->currentPort();
if (!in_array($port, [ fa... | php | {
"resource": ""
} |
q237525 | Url.currentPath | train | public function currentPath()
{
$requestURI = $this->serverVar('REQUEST_URI');
$sciptName = $this->serverVar('SCRIPT_NAME');
return rtrim(parse_url($requestURI? : $sciptName, PHP_URL_PATH), '/');
} | php | {
"resource": ""
} |
q237526 | Url.fetch | train | public function fetch($forwardCookie = true, $contextOptions = [])
{
$cookie = $this->serverVar('HTTP_COOKIE');
if ($forwardCookie && $cookie !== false) {
$cookie = ['http' => ['header' => 'Cookie: '.$cookie."\r\n"]];
$contextOptions = array_merge($cookie, $contextOpt... | php | {
"resource": ""
} |
q237527 | Url.toString | train | public function toString()
{
$result = "";
if ($this->scheme) {
$result .= $this->scheme.'://';
}
if ($this->user) {
$result .= $this->user;
if ($this->pass) {
$result .= $this->user;
}
$result .= '@';
... | php | {
"resource": ""
} |
q237528 | UnitAssertTrait.normalizeArrayForNewLines | train | private function normalizeArrayForNewLines(array $data) {
foreach($data as $k => $item) {
if(is_string($item)) {
$data[$k] = str_replace(["\r\n", "\n\r", "\r"], "\n", $item);
} elseif(is_array($item)) {
$data[$k] = $this->normalizeArrayForNewLines($item);
}
}
return $data;
} | php | {
"resource": ""
} |
q237529 | DIContainerMaintainer.isUseableRaikiri | train | public function isUseableRaikiri($class)
{
$traits = [];
do {
$traits = array_merge($traits, class_uses($class));
} while ($class = get_parent_class($class));
foreach ($traits as $trait) {
$traits = array_merge($traits, class_uses($trait));
}
... | php | {
"resource": ""
} |
q237530 | EventosController.show | train | public function show(Request $request, Evento $evento)
{
Debugbar::info($evento);
return view('multimedia::eventos/show', [
'evento' => $evento,
]);
} | php | {
"resource": ""
} |
q237531 | DeployCommand.deploy | train | protected function deploy($server, $deployer, OutputInterface $output)
{
$plum = $this->getContainer()->get('madalynn.plum');
$options = $plum->getOptions($server);
$dryrun = '';
if (isset($options['dry_run']) && $options['dry_run']) {
$dryrun = '<comment>(dry run mod... | php | {
"resource": ""
} |
q237532 | ProfilesController.searchAction | train | public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, 'Modules\User\Models\Profiles', $this->request->getPost());
$this->persistent->searchParams = $query->getParams();
} else {
$numberPag... | php | {
"resource": ""
} |
q237533 | ProfilesController.createAction | train | public function createAction()
{
if ($this->request->isPost()) {
$profile = new Profiles([
'name' => $this->request->getPost('name', 'striptags'),
'active' => $this->request->getPost('active')
]);
if (!$profile->save()) {
... | php | {
"resource": ""
} |
q237534 | ProfilesController.editAction | train | public function editAction($id)
{
$profile = Profiles::findFirstById($id);
if (!$profile) {
$this->flash->error("Profile was not found");
return $this->dispatcher->forward([
'action' => 'index'
]);
}
if ($this->request->isPost()) {... | php | {
"resource": ""
} |
q237535 | ProfilesController.deleteAction | train | public function deleteAction($id)
{
$profile = Profiles::findFirstById($id);
if (!$profile) {
$this->flash->error("Profile was not found");
return $this->dispatcher->forward([
'action' => 'index'
]);
}
if (!$profile->delete()) {
... | php | {
"resource": ""
} |
q237536 | CurrencyService.restoreState | train | public function restoreState()
{
if ($activeCurrency = $this->stateService->getByKey(self::ACTIVE_CURRENCY_KEY)) {
$this->activeCurrency = $activeCurrency;
}
} | php | {
"resource": ""
} |
q237537 | CurrencyService.convert | train | public function convert(Money $amount, IdentifierInterface $to)
{
if (!$toCurrency = $this->getCurrency($to)) {
throw new \InvalidArgumentException("Currency not supported");
}
/** @var \Heystack\Ecommerce\Currency\Interfaces\CurrencyInterface $fromCurrency */
$fromCurre... | php | {
"resource": ""
} |
q237538 | DefaultScheduler.getNextBuildTime | train | public function getNextBuildTime(BuildInterface $build)
{
if ($build->getLastBuild()->getBuildTime() == null
&& $build->getStatus() !== BuildInterface::STOPPED
) {
if (!isset($this->_nextBuildTime)) {
$this->_nextBuildTime = time();
}
... | php | {
"resource": ""
} |
q237539 | BBcodeDocumentElement.getAsPreviewHTML | train | public function getAsPreviewHTML()
{
$html = "";
foreach ($this->getChildren() as $child) {
$html .= $child->getAsPreviewHTML();
}
return $html;
} | php | {
"resource": ""
} |
q237540 | Adapter.chmod | train | public function chmod($path, $mod = 0777)
{
if ($this->adapter instanceof Local) {
return chmod($path, $mod);
}
return false;
} | php | {
"resource": ""
} |
q237541 | Tree.getNodes | train | public function getNodes()
{
$nodes = array();
foreach ($this->nodes[$this->options['rootid']]->getDescendants() as $subnode) {
$nodes[] = $subnode;
}
return $nodes;
} | php | {
"resource": ""
} |
q237542 | Tree.getNodeById | train | public function getNodeById($id)
{
if (empty($this->nodes[$id])) {
throw new \InvalidArgumentException("Invalid node primary key $id");
}
return $this->nodes[$id];
} | php | {
"resource": ""
} |
q237543 | Tree.getNodeByValuePath | train | public function getNodeByValuePath($name, array $search)
{
$findNested = function (array $nodes, array $tokens) use ($name, &$findNested) {
$token = array_shift($tokens);
foreach ($nodes as $node) {
$nodeName = $node->get($name);
if ($nodeName === $tok... | php | {
"resource": ""
} |
q237544 | Tree.build | train | private function build(array $data)
{
$children = array();
// Create the root node
$this->nodes[$this->options['rootid']] = $this->createNode(
array(
'id' => $this->options['rootid'],
'parent' => null,
)
);
foreach... | php | {
"resource": ""
} |
q237545 | ErrorHandler.setRunningEnvironment | train | public function setRunningEnvironment($running_env)
{
$running_env = (string)$running_env;
if (empty($running_env)) {
$this->toss(
"InvalidArgument",
"The environment name cannot be empty."
);
}
$previous = $this->runni... | php | {
"resource": ""
} |
q237546 | ErrorHandler.handle | train | public function handle($running_env = self::DEFAULT_ENVIRONMENT, callable $callback = null)
{
$is_handled = false;
if (!$this->is_handling && !$this->last_error) {
$this->swapCallable($running_env, $callback, $this->running_env, false);
$this->setRunningEnvironment($running_e... | php | {
"resource": ""
} |
q237547 | ErrorHandler.unhandle | train | public function unhandle()
{
$is_unhandled = false;
if ($this->is_handling && !$this->last_error) {
if ($this->prev_exception_handler) {
set_exception_handler($this->prev_exception_handler);
$this->prev_exception_handler = null;
}
i... | php | {
"resource": ""
} |
q237548 | ErrorHandler.setCallback | train | public function setCallback($env, callable $callable = null)
{
$this->swapCallable($env, $callable, $this->running_env);
$this->callbacks[$env] = $callable;
if (empty($this->errors[$env])) {
$this->setCoreErrors($env, self::getDefaultCoreErrors());
}
if (... | php | {
"resource": ""
} |
q237549 | ErrorHandler.getCallback | train | public function getCallback($env = null)
{
$env = $env ?: $this->running_env;
return isset($this->callbacks[$env]) ? $this->callbacks[$env] : null;
} | php | {
"resource": ""
} |
q237550 | ErrorHandler.defaultCallback | train | public function defaultCallback($handler)
{
$exception = $handler->getLastError();
if (php_sapi_name() != "cli") {
$message = htmlspecialchars($exception->getMessage());
$trace = nl2br(htmlspecialchars($exception->getTraceAsString()));
echo "<!DOCTYPE html><... | php | {
"resource": ""
} |
q237551 | ErrorHandler.setCoreErrors | train | public function setCoreErrors($env, $errors = 0)
{
$this->swapArgs($env, $errors, $this->running_env, false);
$this->errors[$env] = $errors;
if (!$this->getCallback($env)) {
$this->setCallback($env, $this->getDefaultCallback());
}
return $this;
... | php | {
"resource": ""
} |
q237552 | ErrorHandler.getCoreErrors | train | public function getCoreErrors($env = null)
{
$env = $env ?: $this->running_env;
return isset($this->errors[$env]) ? $this->errors[$env] : 0;
} | php | {
"resource": ""
} |
q237553 | ErrorHandler.removeCoreError | train | public function removeCoreError($env, $error = 0)
{
$this->swapArgs($env, $error, $this->running_env);
$is_removed = false;
if (isset($this->errors[$env])) {
$orig = $this->errors[$env];
$this->errors[$env] = ($this->errors[$env] & ~ $error);
$is_... | php | {
"resource": ""
} |
q237554 | ErrorHandler.setUncaughtExceptions | train | public function setUncaughtExceptions($env, array $exceptions = [])
{
$this->swapArgs($env, $exceptions, $this->running_env, false);
$this->exceptions[$env] = [];
if (!empty($exceptions)) {
foreach($exceptions as $exception) {
$this->exceptions[$env][] = ... | php | {
"resource": ""
} |
q237555 | ErrorHandler.getUncaughtExceptions | train | public function getUncaughtExceptions($env = null)
{
$env = $env ?: $this->running_env;
return isset($this->exceptions[$env]) ? $this->exceptions[$env] : [];
} | php | {
"resource": ""
} |
q237556 | ErrorHandler.removeUncaughtException | train | public function removeUncaughtException($env, $exception = null)
{
$this->swapArgs($env, $exception, $this->running_env);
$is_removed = false;
if (isset($this->exceptions[$env])) {
$exception = Objects::getFullName($exception);
$is_removed = (bool)Arrays::re... | php | {
"resource": ""
} |
q237557 | ErrorHandler.isHandlingCoreError | train | public function isHandlingCoreError($env, $error = 0)
{
$this->swapArgs($env, $error, $this->running_env);
return isset($this->errors[$env]) && (($this->errors[$env] & $error) === $error);
} | php | {
"resource": ""
} |
q237558 | ErrorHandler.isHandlingUncaughtException | train | public function isHandlingUncaughtException($env, $exception = null)
{
$this->swapArgs($env, $exception, $this->running_env);
$is_handling = false;
if (isset($this->exceptions[$env])) {
if (is_object($exception)) {
$exception = Objects::getFullName($excep... | php | {
"resource": ""
} |
q237559 | ErrorHandler.handleCoreError | train | public function handleCoreError($type, $message, $file, $line)
{
$is_handled = false;
if ($this->is_handling && $this->isHandlingCoreError($type)) {
$exception = new Exceptions\PHPErrorException(
$message,
$type,
$file,
$lin... | php | {
"resource": ""
} |
q237560 | ErrorHandler.getCoreErrorHandler | train | public function getCoreErrorHandler()
{
return function($type, $message, $file, $line) {
return $this->handleCoreError($type, $message, $file, $line);
};
} | php | {
"resource": ""
} |
q237561 | ErrorHandler.triggerError | train | protected function triggerError(Exception $exception, $label)
{
$this->unhandle();
$this->last_error = $exception;
if ($exception instanceof Exceptions\PHPErrorException) {
$type = Errors::toString($exception->getCode());
} else {
$code = $exception->... | php | {
"resource": ""
} |
q237562 | Module.onBootstrap | train | public function onBootstrap($e)
{
$eventManager = $e->getApplication()->getEventManager();
$serviceManager = $e->getApplication()->getServiceManager();
$options = $serviceManager->get('dlcdoctrine_module_options');
if ($options->getEnableAutoFlushFinishListener()) {... | php | {
"resource": ""
} |
q237563 | SchemaGenerator.generate | train | private function generate()
{
$schema = [];
foreach ($this->getTables() as $table) {
$schema[$table] = $this->getTableDefinition($table);
};
foreach (array_keys($schema) as $table) {
$constraints = $this->driver->getConstraints($table);
foreach ... | php | {
"resource": ""
} |
q237564 | SchemaGenerator.get | train | public function get($table = null)
{
$schema = $this->generate();
if ($table !== null) {
if (isset($schema[$table]) === false) {
throw new Exception('Unknown table "' . $table . '"');
}
$schema = $schema[$table];
}
return $schema... | php | {
"resource": ""
} |
q237565 | ControllerDispatcher.dispatch | train | public function dispatch(Route $route)
{
$callback = $route->getCallback();
$params = array_values($route->getData());
if ($callback instanceof Closure) {
return $this->container->resolveClosure($callback, $params);
}
$class = $this->container->make($callback[0]... | php | {
"resource": ""
} |
q237566 | ArticleImporter.importJournalArticles | train | public function importJournalArticles($oldJournalId, $newJournalId, $issueIds, $sectionIds)
{
$articleSql = "SELECT article_id FROM articles WHERE journal_id = :journal_id";
$articleStatement = $this->dbalConnection->prepare($articleSql);
$articleStatement->bindValue('journal_id', $oldJourna... | php | {
"resource": ""
} |
q237567 | ArticleImporter.importCitations | train | public function importCitations($oldArticleId, $article)
{
$this->consoleOutput->writeln("Reading citations...");
$citationSql = "SELECT * FROM citations WHERE assoc_id = :id";
$citationStatement = $this->dbalConnection->prepare($citationSql);
$citationStatement->bindValue('id', $ol... | php | {
"resource": ""
} |
q237568 | ArticleImporter.importAuthors | train | public function importAuthors($oldArticleId, $article)
{
$this->consoleOutput->writeln("Reading authors...");
$authorSql = "SELECT first_name, last_name, email, seq FROM authors " .
"WHERE submission_id = :id ORDER BY first_name, last_name, email";
$authorStatement = $this->dbal... | php | {
"resource": ""
} |
q237569 | RunTaskCommand.fork | train | private function fork()
{
/** @var LoggerInterface $logger */
$logger = $this->getContainer()->get('logger');
if (!$this->getContainer()->get('tenside.config')->isForkingAvailable()) {
$logger->warning('Forking disabled by configuration, execution will block until the command has... | php | {
"resource": ""
} |
q237570 | Page.resolve_url | train | function resolve_url($base, $url) {
if (!strlen($base)) return $url;
// Step 2
if (!strlen($url)) return $base;
// Step 3
if (preg_match('!^[a-z]+:!i', $url)) return $url;
$base = parse_url($base);
if ($url{0} == "#") {
// Step 2 (fragment)
... | php | {
"resource": ""
} |
q237571 | Object.getIdentifier | train | public function getIdentifier()
{
$firstOctet = $this->getType();
if (Identifier::isLongForm($firstOctet)) {
throw new LogicException(sprintf('Identifier of %s uses the long form and must therefor override "Object::getIdentifier()".', get_class($this)));
}
return chr($f... | php | {
"resource": ""
} |
q237572 | ValueTrait.get | train | public function get($key)
{
$getResult = $this->getValue($key);
$unserialized = @unserialize($getResult);
if (Util::hasInternalExpireTime($unserialized)) {
$getResult = $unserialized['v'];
}
return $getResult;
} | php | {
"resource": ""
} |
q237573 | StockTransferItemController.newAction | train | public function newAction(StockTransfer $stockTransfer)
{
$stocktransferitem = new StockTransferItem();
$stocktransferitem->setStockTransfer($stockTransfer);
$form = $this->createForm(new StockTransferItemType(), $stocktransferitem);
return array(
'stocktransferitem' => ... | php | {
"resource": ""
} |
q237574 | StockTransferItemController.createAction | train | public function createAction(Request $request)
{
$stocktransferitem = new StockTransferItem();
$form = $this->createForm(new StockTransferItemType(), $stocktransferitem);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->p... | php | {
"resource": ""
} |
q237575 | StockTransferItemController.editAction | train | public function editAction(StockTransferItem $stocktransferitem)
{
$editForm = $this->createForm(new StockTransferItemType(), $stocktransferitem, array(
'action' => $this->generateUrl('stock_transfersitem_update', array('id' => $stocktransferitem->getid())),
'method' => 'PUT',
... | php | {
"resource": ""
} |
q237576 | StockTransferItemController.updateAction | train | public function updateAction(StockTransferItem $stocktransferitem, Request $request)
{
$editForm = $this->createForm(new StockTransferItemType(), $stocktransferitem, array(
'action' => $this->generateUrl('stock_transfersitem_update', array('id' => $stocktransferitem->getid())),
'meth... | php | {
"resource": ""
} |
q237577 | Ini.processNode | train | private function processNode(array $node): array
{
$config = [];
foreach ($node as $name => $value) {
if (\preg_match('/^num__([0-9]+)$/', $name, $matches)) {
$name = $matches[1];
}
if (\count($nameEx = \explode('.', $name)) > 1) {
... | php | {
"resource": ""
} |
q237578 | Ini.castValue | train | private function castValue(string $value)
{
$value = $this->normalize($value);
if (\preg_match('/^[0-9]+$/', $value)) {
$value = (int)$value;
} elseif (\preg_match('/^[0-9\.]+$/', $value)) {
$value = (float)$value;
} elseif (\preg_match('/^true|false$/', $valu... | php | {
"resource": ""
} |
q237579 | Ini.normalize | train | private function normalize(string $string): string
{
return \str_replace($this->normalizeFrom, $this->normalizeTo, $string);
} | php | {
"resource": ""
} |
q237580 | HydratorFactory.hydrate | train | public function hydrate($document, $data, array $hints = array())
{
$metadata = $this->dm->getClassMetadata(get_class($document));
// Invoke preLoad lifecycle events and listeners
if ( ! empty($metadata->lifecycleCallbacks[Events::preLoad])) {
$args = array(&$data);
$... | php | {
"resource": ""
} |
q237581 | Helpers.isEmailAddressPrimaryType | train | public function isEmailAddressPrimaryType($emailID) {
// Must we accept "primary" email type only?
if (!Config::get('lasallecrmlistmanagement.listmgmt_emails_in_list_primary_type_only')) {
return false;
}
// "primary" type is #1
if ($this->getEmailType($emailID) != ... | php | {
"resource": ""
} |
q237582 | Reader.bit16 | train | public static function bit16(string $data, int $offset = 0, $endianness = false): int
{
// big-endian
if (true === $endianness) {
return unpack('n', $data, $offset)[1];
}
// little-endian
if (false === $endianness) {
return unpack('v', $data, $offset)... | php | {
"resource": ""
} |
q237583 | Reader.bit64 | train | public static function bit64(string $data, int $offset = 0, bool $endianness = false): int
{
// big-endian
if (true === $endianness) {
return unpack('J', $data, $offset)[1];
}
// little-endian
if (false === $endianness) {
return unpack('P', $data, $of... | php | {
"resource": ""
} |
q237584 | MaterialTableTable.row | train | public function row(& $material, Pager & $pager = null, $module = NULL)
{
/** @var string $tdHTML Table cell HTML code */
$tdHTML = '';
$input = null;
/** @var \samson\cms\CMSField $field Field of current table structure (Table column) */
foreach ($this->fields as $field) {
... | php | {
"resource": ""
} |
q237585 | AbstractProviderFactory.extractAuthEndpoint | train | private function extractAuthEndpoint()
{
$auth = empty($this->config['auth_endpoint']) ? self::DEFAULT_AUTH_ENDPOINT : $this->config['auth_endpoint'];
switch ($auth) {
case Endpoint::UK:
$endpoint = Rackspace::UK_IDENTITY_ENDPOINT;
break;
case... | php | {
"resource": ""
} |
q237586 | CacheKeyFormatter.getDefaultTypeHandler | train | protected function getDefaultTypeHandler($value) {
//get value type
$type = gettype($value);
switch ($type) {
case 'null':
return null;
case 'array':
//check empty array
if (count($value) == 0)
return null;
elseif (count($value) == 1) //get first value type hanlder
return $this->... | php | {
"resource": ""
} |
q237587 | CacheKeyFormatter.castArray | train | protected function castArray($value, TypeHandler $typeHandler, $join_string = ',') {
$list = [];
//build expression list
foreach ($value as $val) {
$val = $typeHandler->castParameter($val);
if (is_null($val))
$new_elem = 'NULL';
else {
$new_elem = $typeHandler->setParameter($val);
if (is_... | php | {
"resource": ""
} |
q237588 | CacheKeyFormatter.castParameter | train | protected function castParameter($value, $type = null) {
//check null value
if (is_null($value))
return 'NULL';
elseif (is_null($type)) {
//obtain default type handler
$typeHandler = $this->getDefaultTypeHandler($value);
if (is_null($typeHandler))
return 'NULL';
if (is_array($value))
return... | php | {
"resource": ""
} |
q237589 | CacheKeyFormatter.replaceConfigExpression | train | protected function replaceConfigExpression($matches) {
$property = $matches[1];
//check key existence
if (!array_key_exists($property, $this->config))
return '';
//convert to string, if possible
if (($str = $this->toString($this->config[$property])) === false)
return '';
return $str;
} | php | {
"resource": ""
} |
q237590 | CacheKeyFormatter.replacePropertyExpression | train | protected function replacePropertyExpression($matches) {
//count available matches
//this indicates the type of expression to replace
$total_matches = count($matches);
$type = $subindex = null;
switch ($total_matches) {
/*
* Property
*/
case 4: //#{PROPERTY@1[INDEX]@2?:TYPE@3}
$type = subs... | php | {
"resource": ""
} |
q237591 | CacheKeyFormatter.replaceArgumentExpression | train | protected function replaceArgumentExpression($matches) {
//count available matches
//this indicates the type of expression to replace
$total_matches = count($matches);
$type = $subindex = null;
//%{TYPE|CLASS@1}
if ($total_matches == 2) {
//check if there are arguments left
if ($this->counter >= cou... | php | {
"resource": ""
} |
q237592 | Validate.isEmail | train | public static function isEmail($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return filter_var((string) $value, FILTER_VALIDATE_EMAIL) !== false;
} | php | {
"resource": ""
} |
q237593 | Validate.isIpAddress | train | public static function isIpAddress($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return filter_var((string) $value, FILTER_VALIDATE_IP) !== false;
} | php | {
"resource": ""
} |
q237594 | Validate.isIpV4Address | train | public static function isIpV4Address($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return filter_var((string) $value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false;
} | php | {
"resource": ""
} |
q237595 | Validate.isIpV6Address | train | public static function isIpV6Address($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return filter_var((string) $value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
} | php | {
"resource": ""
} |
q237596 | Validate.isUri | train | public static function isUri($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
// http://tools.ietf.org/html/rfc3986
//
// URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
// hier-part = "//" authority path-abempt... | php | {
"resource": ""
} |
q237597 | Validate.isUrn | train | public static function isUrn($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
// http://tools.ietf.org/html/rfc2141#section-2.1
// To avoid confusion with the "urn:" identifier, the NID "urn" is
// reserved and MUST NOT be used
if ... | php | {
"resource": ""
} |
q237598 | Validate.isUuid | train | public static function isUuid($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
// http://tools.ietf.org/html/rfc4122
//
// UUID = time-low "-" time-mid "-"
// time-high-and-version "-"
... | php | {
"resource": ""
} |
q237599 | Validate.isTimezone | train | public static function isTimezone($value): bool
{
if ($value instanceof DateTimeZone) {
return true;
}
if (!static::isStringCastable($value)) {
return false;
}
return self::isValidTimezone((string) $value);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.