_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q240000
|
DbManagementTable.convertValue
|
train
|
private function convertValue($value, $type){
switch($type){
case "is_numeric":
$value = floatval($value);
break;
case "is_float":
$value = floatval($value);
break;
case "is_string":
$value = strval($value);
break;
default:
$value = strval($value);
}
return $value;
}
|
php
|
{
"resource": ""
}
|
q240001
|
EventProcessor.process
|
train
|
public function process(EventRecord $eventRecord): void
{
$this->eventStore->append($eventRecord);
$this->eventDispatcher->dispatch($eventRecord->eventMessage());
}
|
php
|
{
"resource": ""
}
|
q240002
|
Html.create
|
train
|
public static function create($name, $content = '', $singleTag = false): Element
{
return new Element($name, $content, $singleTag);
}
|
php
|
{
"resource": ""
}
|
q240003
|
SimpleString.isSameString
|
train
|
public function isSameString($leftString, $rightString)
{
if (is_string($leftString) && is_string($rightString) &&
strlen($leftString) == strlen($rightString) &&
md5($leftString) == md5($rightString)
)
{
return true;
}
return false;
}
|
php
|
{
"resource": ""
}
|
q240004
|
Runner.runInstallers
|
train
|
public function runInstallers(PackageWrapper $package, $isDevMode)
{
foreach ($this->installers as $installer) {
if ($installer->supports($package)) {
$this->io->write(
sprintf(
'<info>Running %s installer for %s</info>',
$installer->getName(),
$package->getPackage()->getPrettyName()
)
);
$installer->install($package, $isDevMode);
}
}
}
|
php
|
{
"resource": ""
}
|
q240005
|
Runner.runBuildTools
|
train
|
public function runBuildTools(PackageWrapper $package, $isDevMode)
{
foreach ($this->buildTools as $buildTool) {
if ($buildTool->supports($package)) {
$this->io->write(
sprintf(
'<info>Running %s builder for %s</info>',
$buildTool->getName(),
$package->getPackage()->getPrettyName()
)
);
$buildTool->build($package, $isDevMode);
}
}
}
|
php
|
{
"resource": ""
}
|
q240006
|
Application.registerHook
|
train
|
public function registerHook ($key, Hook $hook)
{
if (isset($this->hooks[$key])) {
throw new ReregisterHookException('Attempt to re-register hook ' . $key);
}
if (! $key || ! is_string($key)) {
throw new InvalidHookIdentifierException('Invalid hook identifier ' . var_export($key, true));
}
$this->hooks[$key] = $hook;
}
|
php
|
{
"resource": ""
}
|
q240007
|
Application.bindHook
|
train
|
public function bindHook ($key, $closure, $precedence = 0)
{
if (isset($this->hooks[$key])) {
$this->hooks[$key]->bind($closure, $precedence);
} else {
throw new UnregisteredHookException('Attempt to bind unregistered hook ' . $key);
}
}
|
php
|
{
"resource": ""
}
|
q240008
|
Application.triggerHook
|
train
|
public function triggerHook ($key, $args = array(), $precedence = null)
{
if (isset($this->hooks[$key])) {
return $this->hooks[$key]->trigger($args, $precedence);
} else {
throw new UnregisteredHookException('Attempt to trigger unregistered hook ' . $key);
}
}
|
php
|
{
"resource": ""
}
|
q240009
|
LightModel.typeCastModel
|
train
|
private static function typeCastModel(LightModel $model)
{
if (in_array(self::OPTIONS_TYPECAST, self::$initOptions))
{
foreach ($model->getTable()->getColumns() as $column)
{
/* @var $column Column */
if (in_array($column->getField(), get_object_vars($model)))
{
if ($column->getType() === Column::TYPE_INT)
{
$field = $column->getField();
settype($model->$field, Column::TYPE_INT);
}
}
}
}
return $model;
}
|
php
|
{
"resource": ""
}
|
q240010
|
LightModel.init
|
train
|
public static function init(PDO $pdo, $options = [])
{
DB::init($pdo);
self::$initOptions = $options;
}
|
php
|
{
"resource": ""
}
|
q240011
|
LightModel.getTableName
|
train
|
public function getTableName(): string
{
if ($this->tableName === null)
{
$this->tableName = (new \ReflectionClass($this))->getShortName();
}
return $this->tableName;
}
|
php
|
{
"resource": ""
}
|
q240012
|
LightModel.handleFilter
|
train
|
private static function handleFilter(String &$sql, $filter, LightModel $class): array
{
$params = [];
if (isset($filter[self::FILTER_ORDER]))
{
$order = $filter[self::FILTER_ORDER];
unset($filter[self::FILTER_ORDER]);
}
if (isset($filter[self::FILTER_LIMIT]))
{
$limit = (int) $filter[self::FILTER_LIMIT];
unset($filter[self::FILTER_LIMIT]);
}
foreach ($filter as $filter => $value)
{
if (! $class->getTable()->hasColumn($filter))
continue;
//Default operator for all queries
$operator = '=';
//Check if the operator was passed in
if (is_array($value))
{
$operator = $value[0];
$value = $value[1];
}
switch ($class->getTable()->getColumn($filter)->getType())
{
case Column::TYPE_INT:
$value = (int) $value;
break;
default:
$value = (string) $value;
}
$sql .= ' AND `' . $filter . '` ' . $operator . ' :' . $filter;
$params[':' . $filter] = $value;
}
if (isset($order))
{
$sql .= ' ORDER BY ' . $order;
}
if (isset($limit))
{
$sql .= ' LIMIT ' . $limit;
}
return $params;
}
|
php
|
{
"resource": ""
}
|
q240013
|
LightModel.getItems
|
train
|
public static function getItems($filter = []): array
{
$res = [];
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$sql = 'SELECT * FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
foreach ($query->fetchAll(PDO::FETCH_CLASS, $className) as $item)
{
$res[] = self::typeCastModel($item);
}
return $res;
}
|
php
|
{
"resource": ""
}
|
q240014
|
LightModel.getKeys
|
train
|
public static function getKeys($filter = []): array
{
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$tableKey = $class->getKeyName();
$sql = 'SELECT ' . $tableKey . ' FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
$res = [];
foreach ($query->fetchAll() as $key => $value)
{
$res[] = $value[0];
}
return $res;
}
|
php
|
{
"resource": ""
}
|
q240015
|
LightModel.count
|
train
|
public static function count($filter = []): int
{
/* @var $class LightModel */
$className = get_called_class();
$class = new $className;
$tableKey = $class->getKeyName();
$sql = 'SELECT COUNT(' . $tableKey . ') FROM ' . $class->getTableName() . ' WHERE 1=1';
$params = self::handleFilter($sql, $filter, $class);
$query = DB::getConnection()->prepare($sql);
$query->execute($params);
return (int) $query->fetchColumn(0);
}
|
php
|
{
"resource": ""
}
|
q240016
|
LightModel.exists
|
train
|
public function exists(): bool
{
$tableKey = $this->getKeyName();
//If key isn't set we cant associate this record with DB
if (! isset($this->$tableKey))
{
return false;
}
$sql = 'SELECT EXISTS(SELECT ' . $tableKey . ' FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key LIMIT 1)';
$query = DB::getConnection()->prepare($sql);
$query->execute(['key' => $this->getKey()]);
return boolval($query->fetchColumn(0));
}
|
php
|
{
"resource": ""
}
|
q240017
|
LightModel.refresh
|
train
|
public function refresh()
{
$keyName = $this->keyName;
//If we don't have a key we cant refresh
if (! isset($this->$keyName))
{
return;
}
$dbItem = self::getOneByKey($this->getKey());
//Check if we are already the same
if ($dbItem == $this)
{
return;
}
//Get values from DB & check if they match. Update if needed
foreach (get_object_vars($dbItem) as $var => $val)
{
if ($this->$var !== $val)
{
$this->$var = $val;
}
}
}
|
php
|
{
"resource": ""
}
|
q240018
|
LightModel.delete
|
train
|
public function delete(): bool
{
if (! $this->exists())
{
return false;
}
$sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key';
$query = DB::getConnection()->prepare($sql);
return $query->execute(['key' => $this->getKey()]);
}
|
php
|
{
"resource": ""
}
|
q240019
|
LightModel.belongsTo
|
train
|
protected function belongsTo($class, $foreignKey): ?LightModel
{
$identifier = implode('_', [$class, $foreignKey]);
if (! isset($this->_belongsTo[$identifier]))
{
if (! $this->getTable()->hasColumn($foreignKey))
{
throw new ColumnMissingException($this->getTableName() . ' does not have column: ' . $foreignKey);
}
$this->_belongsTo[$identifier] = $class::getOneByKey($this->$foreignKey);
}
return $this->_belongsTo[$identifier];
}
|
php
|
{
"resource": ""
}
|
q240020
|
Date.getAge
|
train
|
public function getAge($day, $month, $year) {
$years = date('Y') - $year;
if (date('m') < $month)
$years--;
elseif (date('d') < $day && date('m') == $month)
$years--;
return $years;
}
|
php
|
{
"resource": ""
}
|
q240021
|
ClassType.getProperties
|
train
|
public function getProperties()
{
//todo cache
$result = array();
foreach ($this->getReflectionClass()->getProperties() as $m)
{
$result[] = PropertyInfo::__internal_create($this, $m);
}
return $result;
}
|
php
|
{
"resource": ""
}
|
q240022
|
ClassType.getProperty
|
train
|
public function getProperty($name)
{
$m = $this->getReflectionClass()->getProperty($name);
return PropertyInfo::__internal_create($this, $m);
}
|
php
|
{
"resource": ""
}
|
q240023
|
ClassType.isAssignableFrom
|
train
|
public function isAssignableFrom(Type $type)
{
if ($type->getName() === $this->getName())
return true;
if (!($type instanceof ClassType))
return false;
return $type->isSubtypeOf($this);
}
|
php
|
{
"resource": ""
}
|
q240024
|
ClassType.isAssignableFromValue
|
train
|
public function isAssignableFromValue($value)
{
if (!is_object($value))
return false;
if (get_class($value) === $this->getName())
return true;
return is_subclass_of($value, $this->className);
}
|
php
|
{
"resource": ""
}
|
q240025
|
ClassType.getImplementedInterfaces
|
train
|
public function getImplementedInterfaces()
{
$result = array();
foreach ($this->getReflectionClass()->getInterfaces() as $interface)
{
$result[] = Type::byReflectionClass($interface);
}
return $result;
}
|
php
|
{
"resource": ""
}
|
q240026
|
DateTransformer.reverseTransform
|
train
|
public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value)
{
if (false === $date = $this->createDateFromString($value)) {
$date = null;
}
$this->propertyAccessor->setValue($modelData, $propertyPath, $date);
}
|
php
|
{
"resource": ""
}
|
q240027
|
I18n.getText
|
train
|
public function getText($sValue)
{
//ad callback to add translation before Apollina - You could see the method use in Venus2
foreach (self::$_aCallbacks as $aOneCallback) {
$sValueReturn = $aOneCallback($sValue);
if ($sValueReturn !== '') { return $sValueReturn; }
}
if (file_exists($this->getI18nDirectory().$this->getLanguage().$this->getIntermediaiteDirectory().$this->getI18nDomain().'.json')) {
if (!Translator::isConfigurated()) {
Translator::setConfig($this->getI18nDirectory().$this->getLanguage().$this->getIntermediaiteDirectory().$this->getI18nDomain().'.json');
}
return Translator::_($sValue);
}
else if (!function_exists("gettext")) {
if (!Gettext::isConfigurated()) { Gettext::setConfig($this->getLanguage(), $this->getI18nDomain(), $this->getI18nDirectory()); }
return Gettext::_($sValue);
}
else {
return Mock::_($sValue);
}
}
|
php
|
{
"resource": ""
}
|
q240028
|
BaseProcessor.normalize
|
train
|
protected function normalize(array $input) : array
{
$normalized = [];
foreach ($this->rules() as $field => $value) {
$normalized[$field] = $input[$field] ?? '';
}
return $normalized;
}
|
php
|
{
"resource": ""
}
|
q240029
|
Val.prop
|
train
|
public static function prop($value, $chain)
{
if (empty($chain)) {
throw new \InvalidArgumentException("Value property name cannot be empty.");
}
if (!is_string($chain)) {
throw new \InvalidArgumentException(sprintf(
"Value property name must be a string, %s given.",
gettype($chain)
));
}
$chain = explode('.', $chain);
foreach ($chain as $property) {
if (is_object($value)) {
$getter = 'get' . ucfirst($property);
if (is_callable(array($value, $getter))) {
$value = $value->$getter();
} elseif (isset($value->{$property})) {
$value = $value->{$property};
} else {
return null;
}
} elseif (Arrays::isArray($value)) {
if (!isset($value[$property])) {
return null;
}
$value = $value[$property];
} elseif (is_null($value)) {
return null;
} else {
throw new \InvalidArgumentException(sprintf(
"Value property '%s' in chain '%s' has invalid type: '%s'.",
$property,
$chain,
gettype($value)
));
}
}
return $value;
}
|
php
|
{
"resource": ""
}
|
q240030
|
Val.props
|
train
|
public static function props($value, array $chains)
{
$props = array();
foreach ($chains as $chain) {
$props[$chain] = static::prop($value, $chain);
}
return $props;
}
|
php
|
{
"resource": ""
}
|
q240031
|
Val.nulls
|
train
|
public static function nulls(array $data, $keys = null)
{
if ($keys === null) {
$keys = array_keys($data);
}
if (!Arrays::isArray($keys)) {
$keys = array($keys);
}
foreach ($keys as $key) {
if (array_key_exists($key, $data) && empty($data[$key])) {
$data[$key] = null;
}
}
return $data;
}
|
php
|
{
"resource": ""
}
|
q240032
|
Val.string
|
train
|
public static function string($value)
{
if (static::stringable($value)) {
$value = (string) $value;
} else {
$value = null;
}
return $value;
}
|
php
|
{
"resource": ""
}
|
q240033
|
Val.hash
|
train
|
public static function hash($value)
{
$hash = is_object($value)
? spl_object_hash($value)
: md5(Php::encode($value));
return $hash;
}
|
php
|
{
"resource": ""
}
|
q240034
|
ActivationToken.generateSelector
|
train
|
private function generateSelector(): string
{
// Make sure the selector is not in use. Such case is very uncommon and rare but can happen.
$in_use = true;
while ($in_use == true) {
// Generate random selector and token
$this->setSize(6);
$this->generateRandomToken();
$selector = bin2hex($this->token);
// And check if it is already in use
$in_use = $this->db->count('core_activation_tokens', 'selector = :selector', [
'selector' => $selector
]) > 0;
}
$this->selector = $selector;
return $this->selector;
}
|
php
|
{
"resource": ""
}
|
q240035
|
ActivationToken.getSelector
|
train
|
public function getSelector(bool $refresh = false): string
{
if (!isset($this->selector) || $refresh) {
$this->generateSelector();
}
return $this->selector;
}
|
php
|
{
"resource": ""
}
|
q240036
|
ActivationToken.generateActivationToken
|
train
|
private function generateActivationToken(): string
{
$this->setSize(32);
$this->generateRandomToken();
$this->activation_token = hash('sha256', $this->token);
return $this->activation_token;
}
|
php
|
{
"resource": ""
}
|
q240037
|
CreateServiceRequest.linkTo
|
train
|
public function linkTo(Service $service, $name = null)
{
$link = [
'to_service' => $service->getResourceUri()
];
if (!is_null($name)) {
$link['name'] = $name;
}
$this->linked_to_service[] = $link;
}
|
php
|
{
"resource": ""
}
|
q240038
|
ThemeMegaMenu.registerFields
|
train
|
public function registerFields($id, $item, $depth, $args)
{
foreach ($this->fields as $_key => $data) :
$key = sprintf('menu-item-%s', $_key);
$id = sprintf('edit-%s-%s', $key, $item->ID);
$name = sprintf('%s[%s]', $key, $item->ID);
$value = get_post_meta($item->ID, $key, true);
$class = sprintf('field-%s', $_key);
?>
<p class="description description-wide <?php echo esc_attr($class) ?>">
<?php if ($data["type"] == "bool"): ?>
<label>
<?= esc_html($data["name"]) ?><br/>
<select id="<?= esc_attr($id) ?>" class="widefat <?= esc_attr($id) ?>" name="<?= esc_attr($name) ?>">
<option value="0" <?= $value !== 1 ? " selected" : "" ?>><?= __("No", "theme") ?></option>
<option value="1" <?= $value == 1 ? " selected" : "" ?>><?= __("Yes", "theme") ?></option>
</select>
</label>
<?php else: ?>
<label>
<?= esc_html($data["name"]) ?><br/>
<input type="text" id="<?= esc_attr($id) ?>" class="widefat <?= esc_attr($id) ?>" name="<?= esc_attr($name) ?>" value="<?= esc_attr($value) ?>"/>
</label>
<?php endif; ?>
</p>
<?php
endforeach;
}
|
php
|
{
"resource": ""
}
|
q240039
|
BrandElement.createImage
|
train
|
public function createImage($src, $alt = '')
{
/* @var $img \Core\Html\Elements\Img */
$img = $this->factory->create('Elements\Img');
$img->setSrc($src);
if (! empty($alt)) {
$img->setAlt($alt);
}
return $this->content = $img;
}
|
php
|
{
"resource": ""
}
|
q240040
|
RepresentSerializer.toJson
|
train
|
private function toJson($object, $view = null)
{
return json_encode($this->builder->buildRepresentation($object, $view));
}
|
php
|
{
"resource": ""
}
|
q240041
|
ProductService.findAll
|
train
|
public function findAll($page = 1, $max = 50)
{
$offset = (($page - 1) * $max);
$products = $this->getEm()->getRepository("AmulenShopBundle:Product")->findBy(array(), array(), $max, $offset);
return $products;
}
|
php
|
{
"resource": ""
}
|
q240042
|
Message.send
|
train
|
public function send() {
$curl_handle = curl_init();
$postfields=array();
$postfields['token'] = $this->token;
$postfields['user'] = $this->userkey;
$postfields['message'] = $this->message;
$postfields['url'] = $this->url;
$postfields['priority'] = $this->priority;
$postfields['url_title'] = $this->url_title;
$postfields['retry'] = $this->retry;
$postfields['expire'] = $this->expire;
curl_setopt_array($curl_handle,
array(
CURLOPT_URL => $this->pushover_messages_url,
CURLOPT_POSTFIELDS => $postfields,
CURLOPT_RETURNTRANSFER => true,
));
$response = curl_exec($curl_handle);
curl_close($curl_handle);
if (isset($response['status']) && $response['status'] == 1) {
return true;
}
return false;
}
|
php
|
{
"resource": ""
}
|
q240043
|
Language.get
|
train
|
public function get($value)
{
if (!empty($this->_array[$value])) {
return $this->_array[$value];
} else {
return $value;
}
}
|
php
|
{
"resource": ""
}
|
q240044
|
Language.show
|
train
|
public static function show($value, $name, $code = null)
{
if (is_null($code)) $code = self::$_languageCode;
// Lang file
$file = "../App/Language/$code/$name.php";
// Check if is readable
if (is_readable($file)) {
// Require file
$_array = include($file);
} else {
// Display error
echo \Core\Error::display("Could not load language file '$code/$name.php'");
die;
}
if (!empty($_array[$value])) {
return $_array[$value];
} else {
return $value;
}
}
|
php
|
{
"resource": ""
}
|
q240045
|
BBcodeDefinitionFactory.create
|
train
|
public function create(
$tag, $html, $useOption = false, $parseContent = true,
$nestLimit = -1, array $optionValidator = array(), InputValidator $bodyValidator = null
) {
return new $this->className($tag, $html, $useOption, $parseContent, $nestLimit, $optionValidator, $bodyValidator);
}
|
php
|
{
"resource": ""
}
|
q240046
|
GetterInvokerTrait.invokeGetter
|
train
|
protected function invokeGetter(ReflectionProperty $property)
{
$methodName = $this->generateGetterName($property->getName());
if ($this->hasInternalMethod($methodName)) {
return $this->$methodName();
}
throw new UndefinedPropertyException(sprintf(
'No "%s"() method available for property "%s"', $methodName,
$property->getName()
));
}
|
php
|
{
"resource": ""
}
|
q240047
|
GetterInvokerTrait.generateGetterName
|
train
|
protected function generateGetterName(string $propertyName) : string
{
static $methods = [];
if (isset($methods[$propertyName])) {
return $methods[$propertyName];
}
$method = 'get' . ucfirst(Str::camel($propertyName));
$methods[$propertyName] = $method;
return $method;
}
|
php
|
{
"resource": ""
}
|
q240048
|
Auth.loadPrincipalFromRememberMeCookie
|
train
|
private function loadPrincipalFromRememberMeCookie()
{
$hash = cookie('remember_me');
if ($hash === null) {
return;
}
try {
list($id, $token) = explode('|', base64_decode($hash));
}
catch (Exception $e) {
$this->deleteRememberMeCookie();
return;
}
/** @var Model $user */
$model = config('auth.model.class');
$user = call_user_func([$model, 'find'], $id);
//$user = User::find($id);
if ($user !== null && !empty($token) && $token === $user->getAttribute('remember_token')) {
$this->setPrincipal($user->getId(), $user->getAttribute('name'), $user->getAttribute('role'));
}
}
|
php
|
{
"resource": ""
}
|
q240049
|
Auth.getAbilities
|
train
|
private function getAbilities($role)
{
$abilities = [];
foreach (config('auth.acl') as $ability => $roles) {
if (in_array($role, $roles)) {
$abilities[] = $ability;
}
}
return $abilities;
}
|
php
|
{
"resource": ""
}
|
q240050
|
Auth.attribute
|
train
|
private function attribute($key)
{
if ($this->attributes === null) {
$this->attributes = session('_auth', []);
if (empty($this->attributes)) {
$this->loadPrincipalFromRememberMeCookie();
}
}
return isset($this->attributes[$key]) ? $this->attributes[$key] : null;
}
|
php
|
{
"resource": ""
}
|
q240051
|
Zend_Gdata_Books.getVolumeFeed
|
train
|
public function getVolumeFeed($location = null)
{
if ($location == null) {
$uri = self::VOLUME_FEED_URI;
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
}
|
php
|
{
"resource": ""
}
|
q240052
|
Zend_Gdata_Books.getVolumeEntry
|
train
|
public function getVolumeEntry($volumeId = null, $location = null)
{
if ($volumeId !== null) {
$uri = self::VOLUME_FEED_URI . "/" . $volumeId;
} else if ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
$uri = $location;
}
return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry');
}
|
php
|
{
"resource": ""
}
|
q240053
|
Zend_Gdata_Books.getUserLibraryFeed
|
train
|
public function getUserLibraryFeed($location = null)
{
if ($location == null) {
$uri = self::MY_LIBRARY_FEED_URI;
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
}
|
php
|
{
"resource": ""
}
|
q240054
|
Zend_Gdata_Books.getUserAnnotationFeed
|
train
|
public function getUserAnnotationFeed($location = null)
{
if ($location == null) {
$uri = self::MY_ANNOTATION_FEED_URI;
} else {
$uri = $location;
}
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
}
|
php
|
{
"resource": ""
}
|
q240055
|
Sanitizer.findFilter
|
train
|
private function findFilter($filterId) {
foreach(filter_list() as $filterName) {
if(filter_id($filterName)===$filterId) {
return $filterName;
}
}
throw new \Exception('Could not find filter '.$filterId);
}
|
php
|
{
"resource": ""
}
|
q240056
|
Sanitizer.setSanitizeFilter
|
train
|
public function setSanitizeFilter($filter) {
$this->filterName = $this->findFilter($filter);
$this->sanitizeFilter = $filter;
}
|
php
|
{
"resource": ""
}
|
q240057
|
Sanitizer.filter
|
train
|
public function filter($value) {
return $this->checkSanitizedValue(filter_var($value, $this->sanitizeFilter, $this->sanitizeFlags));
}
|
php
|
{
"resource": ""
}
|
q240058
|
Sanitizer.filterEnv
|
train
|
public function filterEnv($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!$this->filterHas(\INPUT_ENV, $variableName)) {
return null;
}
// Sadly INPUT_ENV is broken and does not work
// getenv() has to be used
return $this->filter(getenv($variableName));
}
|
php
|
{
"resource": ""
}
|
q240059
|
Sanitizer.filterSession
|
train
|
public function filterSession($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!isset($_SESSION[$variableName])) {
return null;
}
return $this->filter($_SESSION[$variableName]);
}
|
php
|
{
"resource": ""
}
|
q240060
|
Sanitizer.filterRequest
|
train
|
public function filterRequest($variableName) {
if(!is_string($variableName)) {
throw new \Exception('Variable name expected as string');
}
if(!isset($_REQUEST[$variableName])) {
return null;
}
return $this->filter($_REQUEST[$variableName]);
}
|
php
|
{
"resource": ""
}
|
q240061
|
ConfigurationController.indexAction
|
train
|
public function indexAction() {
$clientSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Flowpack.SingleSignOn.Client');
$clientSettingsYaml = \Symfony\Component\Yaml\Yaml::dump($clientSettings, 99, 2);
$this->view->assign('clientSettings', $clientSettingsYaml);
$authenticationSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow.security.authentication');
$authenticationSettingsYaml = \Symfony\Component\Yaml\Yaml::dump($authenticationSettings, 99, 2);
$this->view->assign('authenticationSettings', $authenticationSettingsYaml);
}
|
php
|
{
"resource": ""
}
|
q240062
|
AtomiumCompileInstructions.open
|
train
|
protected static function open($script, $openTag, $closeChar, $phpFunc, $phpClose)
{
//
$data = Strings::splite($script, $openTag);
//
$output = $data[0];
//
for ($i = 1; $i < Collection::count($data); $i++) {
$items = self::getParmas($data[$i], $closeChar);
//
$params = $items['params'];
$rest = $items['rest'];
//
$output .= self::compile($params, $phpFunc, $phpClose);
$output .= $rest;
}
//
return $output;
}
|
php
|
{
"resource": ""
}
|
q240063
|
AtomiumCompileInstructions.getParmas
|
train
|
protected static function getParmas($row, $closeChar)
{
$params = '';
$rest = '';
$taken = false;
$string = false; // 1 "" - 2 ''
$opened = 0; // 1 "" - 2 ''
//
for ($j = 0; $j < strlen($row); $j++) {
//
if ($row[$j] == "'" && !$string) {
$string = 2;
} elseif ($row[$j] == '"' && !$string) {
$string = 1;
} elseif ($row[$j] == "'" && $string) {
$string = false;
} elseif ($row[$j] == '"' && $string) {
$string = false;
}
//
if ($row[$j] == '(') {
$opened++;
} elseif ($row[$j] == ')') {
$opened--;
}
//
if (!$string && $opened == 0 && $row[$j] == $closeChar && !$taken) {
$taken = true;
} elseif (!$taken) {
$params .= $row[$j];
} elseif ($taken) {
$rest .= $row[$j];
}
}
//
return ['params' => $params, 'rest' => $rest];
}
|
php
|
{
"resource": ""
}
|
q240064
|
EnumerationBase.toArray
|
train
|
public static function toArray() {
$enumClass = get_called_class();
if(!array_key_exists($enumClass, self::$cache)) {
$reflector = new ReflectionClass($enumClass);
self::$cache[$enumClass] = $reflector->getConstants();
}
return self::$cache[$enumClass];
}
|
php
|
{
"resource": ""
}
|
q240065
|
EnumerationBase.isValidKey
|
train
|
public static function isValidKey($key) {
if(!is_string($key)) {
throw EnumerationException::invalidKeyType(gettype($key));
}
return array_key_exists($key, self::toArray());
}
|
php
|
{
"resource": ""
}
|
q240066
|
Template.prepareDisplay
|
train
|
private function prepareDisplay()
{
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Start@OWeb\manage\Template');
//We save the content so that if there is an error we don't show half displayed codes
ob_start();
try {
\OWeb\manage\Controller::getInstance()->display();
} catch (\Exception $e) {
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Fail@OWeb\manage\Template');
ob_end_clean();
ob_start();
$ctr = \OWeb\manage\Controller::getInstance()->loadException($e);
$ctr->addParams("exception", $e);
\OWeb\manage\Controller::getInstance()->display();
}
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Succ@OWeb\manage\Template');
$this->content = ob_get_contents();
\OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_End@OWeb\manage\Template');
ob_end_clean();
//$this->content_heads = \OWeb\manage\Headers::getInstance()->toString();
// \OWeb\manage\Headers::getInstance()->reset();
}
|
php
|
{
"resource": ""
}
|
q240067
|
SnideTravinizerExtension.load
|
train
|
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('model.xml');
$loader->load('form.xml');
$loader->load('helper.xml');
$loader->load('reader.xml');
$loader->load('converter.xml');
$loader->load('loader.xml');
$loader->load('manager.xml');
$loader->load('twig_extension.xml');
$loader->load('validator.xml');
$loader->load('cache.xml');
$this->loadRepository($loader, $container, $config);
$this->loadManager($loader, $container, $config);
$this->loadRepoClass($loader, $container, $config);
$this->loadCachePath($container, $config);
$this->loadVersionEyeKey($container, $config);
}
|
php
|
{
"resource": ""
}
|
q240068
|
SnideTravinizerExtension.loadRepoClass
|
train
|
protected function loadRepoClass($loader, ContainerBuilder $container, array $config)
{
if (isset($config['repository']['repo']['class'])) {
$container->setParameter('snide_travinizer.model.repo.class', $config['repository']['repo']['class']);
}
}
|
php
|
{
"resource": ""
}
|
q240069
|
View.display
|
train
|
public function display(string $key, array $data, int $status = RegularResponse::HTTP_OK): ResponseInterface
{
$content = $this->templateStrategy->render($key, $data);
$this->responseStrategy->setContent($content);
$this->responseStrategy->setStatusCode($status);
return $this->responseStrategy;
}
|
php
|
{
"resource": ""
}
|
q240070
|
Observer_CreatedAt.before_insert
|
train
|
public function before_insert(Model $obj)
{
if ($this->_overwrite or empty($obj->{$this->_property}))
{
$obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
}
}
|
php
|
{
"resource": ""
}
|
q240071
|
Subscriber.getSubscribedEvents
|
train
|
public static function getSubscribedEvents()
{
return [
Events::UPDATE => ['onUpdate',0],
Events::STORE => ['onStore', 0],
sprintf('%s.%s', Backend::IDENTIFIER, TransactionEvents::STORED) => ['onTransactionStored', 0]
];
}
|
php
|
{
"resource": ""
}
|
q240072
|
AbstractRow.submitForm
|
train
|
public function submitForm(array $values)
{
$this->value = isset($values[$this->name]) ? $values[$this->name] : null;
}
|
php
|
{
"resource": ""
}
|
q240073
|
Loader.resolve
|
train
|
protected function resolve(Input $input): Input
{
$this->call($input->value());
$input->ignore();
return $input;
}
|
php
|
{
"resource": ""
}
|
q240074
|
AbstractElement.makeElement
|
train
|
protected function makeElement(array $options, $html)
{
if (isset($options['type']) && $options['type'] == 'hidden') return $html;
if (!empty($options['before-input'])) $html = $options['before-input'].$html;
$html = $this->getLabel($options).$html;
if (!empty($options['after-input'])) $html .= $options['after-input'];
$html .= $this->html->getDivError($options);
$html = $this->html->getFormGroup($options, $html);
if (!empty($options['script'])) $this->appendScript($options['script']);
if (!empty($options['mask'])) $this->appendScript($this->html->getMaskScript($options));
return $this->html->getGrid($options, $html);
}
|
php
|
{
"resource": ""
}
|
q240075
|
Gdn_Cache.Initialize
|
train
|
public static function Initialize($ForceEnable = FALSE, $ForceMethod = FALSE) {
$AllowCaching = self::ActiveEnabled($ForceEnable);
$ActiveCache = Gdn_Cache::ActiveCache();
if ($ForceMethod !== FALSE) $ActiveCache = $ForceMethod;
$ActiveCacheClass = 'Gdn_'.ucfirst($ActiveCache);
if (!$AllowCaching || !$ActiveCache || !class_exists($ActiveCacheClass)) {
$CacheObject = new Gdn_Dirtycache();
} else
$CacheObject = new $ActiveCacheClass();
if (method_exists($CacheObject,'Autorun'))
$CacheObject->Autorun();
// This should only fire when cache is loading automatically
if (!func_num_args() && Gdn::PluginManager() instanceof Gdn_PluginManager)
Gdn::PluginManager()->FireEvent('AfterActiveCache');
return $CacheObject;
}
|
php
|
{
"resource": ""
}
|
q240076
|
Gdn_Cache.ActiveCache
|
train
|
public static function ActiveCache() {
/*
* There is a catch 22 with caching the config file. We need
* an external way to define the cache layer before needing it
* in the config.
*/
if (defined('CACHE_METHOD_OVERRIDE'))
$ActiveCache = CACHE_METHOD_OVERRIDE;
else
$ActiveCache = C('Cache.Method', FALSE);
// This should only fire when cache is loading automatically
if (!func_num_args() && Gdn::PluginManager() instanceof Gdn_PluginManager) {
Gdn::PluginManager()->EventArguments['ActiveCache'] = &$ActiveCache;
Gdn::PluginManager()->FireEvent('BeforeActiveCache');
}
return $ActiveCache;
}
|
php
|
{
"resource": ""
}
|
q240077
|
Gdn_Cache.ActiveEnabled
|
train
|
public static function ActiveEnabled($ForceEnable = FALSE) {
$AllowCaching = FALSE;
if (defined('CACHE_ENABLED_OVERRIDE'))
$AllowCaching |= CACHE_ENABLED_OVERRIDE;
$AllowCaching |= C('Cache.Enabled', FALSE);
$AllowCaching |= $ForceEnable;
return (bool)$AllowCaching;
}
|
php
|
{
"resource": ""
}
|
q240078
|
Gdn_Cache.ActiveStore
|
train
|
public static function ActiveStore($ForceMethod = NULL) {
// Get the active cache name
$ActiveCache = self::ActiveCache();
if (!is_null($ForceMethod))
$ActiveCache = $ForceMethod;
$ActiveCache = ucfirst($ActiveCache);
// Overrides
if (defined('CACHE_STORE_OVERRIDE') && defined('CACHE_METHOD_OVERRIDE') && CACHE_METHOD_OVERRIDE == $ActiveCache)
return unserialize(CACHE_STORE_OVERRIDE);
$apc = false;
if (C('Garden.Apc', false) && C('Garden.Cache.ApcPrecache', false) && function_exists('apc_fetch'))
$apc = true;
$LocalStore = null;
$ActiveStore = null;
$ActiveStoreKey = "Cache.{$ActiveCache}.Store";
// Check memory
if (is_null($LocalStore)) {
if (array_key_exists($ActiveCache, Gdn_Cache::$Stores)) {
$LocalStore = Gdn_Cache::$Stores[$ActiveCache];
}
}
// Check APC cache
if (is_null($LocalStore) && $apc) {
$LocalStore = apc_fetch($ActiveStoreKey);
if ($LocalStore) {
Gdn_Cache::$Stores[$ActiveCache] = $LocalStore;
}
}
if (is_array($LocalStore)) {
// Convert to ActiveStore format (with 'Active' key)
$Save = false;
$ActiveStore = array();
foreach ($LocalStore as $StoreServerName => &$StoreServer) {
$IsDelayed = &$StoreServer['Delay'];
$IsActive = &$StoreServer['Active'];
if (is_numeric($IsDelayed)) {
if ($IsDelayed < time()) {
$IsActive = true;
$IsDelayed = false;
$StoreServer['Fails'] = 0;
$Save = true;
} else {
if ($IsActive) {
$IsActive = false;
$Save = true;
}
}
}
// Add active servers to ActiveStore array
if ($IsActive)
$ActiveStore[] = $StoreServer['Server'];
}
}
// No local copy, get from config
if (is_null($ActiveStore)) {
$ActiveStore = C($ActiveStoreKey, false);
// Convert to LocalStore format
$LocalStore = array();
$ActiveStore = (array)$ActiveStore;
foreach ($ActiveStore as $StoreServer) {
$StoreServerName = md5($StoreServer);
$LocalStore[$StoreServerName] = array(
'Server' => $StoreServer,
'Active' => true,
'Delay' => false,
'Fails' => 0
);
}
$Save = true;
}
if ($Save) {
// Save to memory
Gdn_Cache::$Stores[$ActiveCache] = $LocalStore;
// Save back to APC for later
if ($apc) {
apc_store($ActiveStoreKey, $LocalStore, Gdn_Cache::APC_CACHE_DURATION);
}
}
return $ActiveStore;
}
|
php
|
{
"resource": ""
}
|
q240079
|
Gdn_Cache.Fail
|
train
|
public function Fail($server) {
// Use APC?
$apc = false;
if (C('Garden.Apc', false) && function_exists('apc_fetch'))
$apc = true;
// Get the active cache name
$activeCache = Gdn_Cache::ActiveCache();
$activeCache = ucfirst($activeCache);
$sctiveStoreKey = "Cache.{$activeCache}.Store";
// Get the localstore
$localStore = GetValue($activeCache, Gdn_Cache::$Stores, null);
if (is_null($localStore)) {
Gdn_Cache::ActiveStore();
$localStore = GetValue($activeCache, Gdn_Cache::$Stores, null);
if (is_null($localStore)) {
return false;
}
}
$storeServerName = md5($server);
if (!array_key_exists($storeServerName, $localStore)) {
return false;
}
$storeServer = &$localStore[$storeServerName];
$isActive = &$storeServer['Active'];
if (!$isActive) return false;
$fails = &$storeServer['Fails'];
$fails++;
$active = $isActive ? 'active' : 'inactive';
// Check if we need to deactivate for 5 minutes
if ($isActive && $storeServer['Fails'] > 3) {
$isActive = false;
$storeServer['Delay'] = time() + Gdn_Cache::CACHE_EJECT_DURATION;
}
// Save
Gdn_Cache::$Stores[$activeCache] = $localStore;
// Save to APC
if ($apc) {
apc_store($sctiveStoreKey, $localStore, Gdn_Cache::APC_CACHE_DURATION);
}
return true;
}
|
php
|
{
"resource": ""
}
|
q240080
|
Gdn_Cache.HasFeature
|
train
|
public function HasFeature($Feature) {
return isset($this->Features[$Feature]) ? $this->Features[$Feature] : Gdn_Cache::CACHEOP_FAILURE;
}
|
php
|
{
"resource": ""
}
|
q240081
|
DbAbstract.setConnection
|
train
|
public function setConnection($pHost, $pName, $pUser = NULL, $pPassword = NULL)
{
$this->_connection = $this->connect($pHost, $pName, $pUser, $pPassword);
$this->_dbName = $pName;
return $this;
}
|
php
|
{
"resource": ""
}
|
q240082
|
DbAbstract.getConnection
|
train
|
public function getConnection()
{
if (is_null($this->_connection)) {
$this->setConnection(
Agl::app()->getConfig('main/db/host'),
Agl::app()->getConfig('main/db/name'),
Agl::app()->getConfig('main/db/user'),
Agl::app()->getConfig('main/db/password')
);
}
return $this->_connection;
}
|
php
|
{
"resource": ""
}
|
q240083
|
MapHelper.GetCoordinatesToCenterOverARegion
|
train
|
public static function GetCoordinatesToCenterOverARegion($configManager) {
return array(
"lat" => $configManager->get(\Puzzlout\Framework\Enums\AppSettingKeys::GoogleMapsCenterLat),
"lng" => $configManager->get(\Puzzlout\Framework\Enums\AppSettingKeys::GoogleMapsCenterLng)
);
}
|
php
|
{
"resource": ""
}
|
q240084
|
MapHelper.BuildLatAndLongCoordFromGeoObjects
|
train
|
public static function BuildLatAndLongCoordFromGeoObjects($objects, $latPropName, $lngPropName) {
$coordinates = array();
foreach ($objects as $object) {
if (self::CheckCoordinateValue($object->$latPropName()) && self::CheckCoordinateValue($object->$lngPropName())) {
$coordinate = array(
"lat" => $object->$latPropName(),
"lng" => $object->$lngPropName()
);
array_push($coordinates, $coordinate);
}
}
return $coordinates;
}
|
php
|
{
"resource": ""
}
|
q240085
|
Getopt.addOptions
|
train
|
public function addOptions(array $options) : Getopt
{
if (!empty($this->options)){
$this->options = array_merge($this->options, $options);
}
else{
$this->options = $options;
}
return $this;
}
|
php
|
{
"resource": ""
}
|
q240086
|
Module.hasUser
|
train
|
public static function hasUser()
{
if (!(Yii::$app instanceof Application)) {
return false;
}
if (!Yii::$app->db->getTableSchema(User::tableName())) {
return false;
}
try {
$identityClass = Yii::$app->user->identityClass;
} catch (\Exception $e) {
$identityClass = false;
}
if (!$identityClass) {
return false;
}
return !Yii::$app->user->isGuest;
}
|
php
|
{
"resource": ""
}
|
q240087
|
Str.StartsWith
|
train
|
public static function StartsWith($haystack, $needle)
{
$length = static::Length($needle);
return substr($haystack, 0, $length) === $needle;
}
|
php
|
{
"resource": ""
}
|
q240088
|
Str.EndsWith
|
train
|
public static function EndsWith($haystack, $needle)
{
$length = static::Length($needle);
return $length === 0 || (substr($haystack, -$length) === $needle);
}
|
php
|
{
"resource": ""
}
|
q240089
|
Str.Ucfirst
|
train
|
public static function Ucfirst($str)
{
return function_exists('ucfirst') ?
ucfirst($str) :
static::Upper(substr($str, 0, 1)).substr($str, 1);
}
|
php
|
{
"resource": ""
}
|
q240090
|
ProcedureFactory.parseCommands
|
train
|
private function parseCommands(array $json, string $procedureName)
{
$factory = new CommandFactory($this->app);
$errors = [];
foreach($json as $commandString) {
/* Get the namespace of the command */
$plugin = explode(':', $commandString, 2)[0];
/* Check that the given plugin is installed */
if(! $this->app->getContainer()->hasPlugin($plugin)) {
$errors[] = "Plugin '$plugin' is required to run procedure '$procedureName'.";
continue;
}
$parsedCommands[] = $factory->create($plugin, $commandString);
}
if(! empty($errors)) {
throw new PluginNotFoundException(implode(PHP_EOL, $errors));
}
return $parsedCommands;
}
|
php
|
{
"resource": ""
}
|
q240091
|
ProcedureFactory.parseUntilFound
|
train
|
private function parseUntilFound(string $procedure)
{
/* First check if parsed content has the desired procedure */
foreach($this->parsed as $path => $json) {
if($this->hasProcedure($json, $procedure)) return $json;
}
/* Next, check if the most likely file has the procedure */
$json = $this->findMostLikelyFile($procedure);
if(! is_null($json)) return $json;
/* Lastly, check rest of the files one by one */
foreach($this->unparsedPaths() as $path) {
$json = $this->parsePath($path);
if($this->hasProcedure($json, $procedure)) return $json;
}
return null;
}
|
php
|
{
"resource": ""
}
|
q240092
|
ProcedureFactory.findMostLikelyFile
|
train
|
private function findMostLikelyFile(string $procedure)
{
foreach($this->paths as $path) {
$filename = Strings::afterLast($path, '/');
$filenameWithoutExtension = Strings::untilLast($filename, '.');
if($procedure === $filenameWithoutExtension) {
return $filename;
}
}
return null;
}
|
php
|
{
"resource": ""
}
|
q240093
|
DoctrineResourceManager.getQueryBuilder
|
train
|
protected function getQueryBuilder($repositoryMethod)
{
$repository = $this
->getDriver()
->getDoctrineOrmEm()
->getRepository($this->getDriver()->getEntityFqn())
;
$repositoryMethods = $this->getDriver()->getEntityRepositorySearchableMethods();
if (!method_exists($repository, $repositoryMethods[$repositoryMethod])) {
return $repository->createQueryBuilder($this->getDriver()->getEntityAlias());
}
$queryBuilder = $repository->{$repositoryMethods[$repositoryMethod]}();
if (!$queryBuilder instanceof QueryBuilder) {
throw new ResourceException(sprintf(
'The method "%s" of repository class must be return a %s instance',
$repositoryMethods[$repositoryMethod],
'\Doctrine\ORM\QueryBuilder'
));
}
return $queryBuilder;
}
|
php
|
{
"resource": ""
}
|
q240094
|
MessageAbstract.setTimestamp
|
train
|
public function setTimestamp($timestamp)
{
if (!$timestamp instanceof \DateTime) {
$date = new \DateTime();
$date->setTimestamp($timestamp);
} else {
$date = $timestamp;
}
$this->header['TIMESTAMP'] = $date->format('M d H:i:s');
return $this;
}
|
php
|
{
"resource": ""
}
|
q240095
|
NumberExtension.formatNumberToHumanReadable
|
train
|
public function formatNumberToHumanReadable($number, $precision = 0, $method = 'common')
{
if ($number >= 1000000) {
// Divide by 1000000 to get 1M, 1.23M, etc.
$value = $number / 1000000;
$extension = 'M';
} elseif ($number >= 1000 && $number < 1000000) {
// Divide by 1000, to get 1K, 1.33K, etc.
$value = $number / 1000;
$extension = 'K';
} else {
// Less than 1000, just return the number, unformatted, not rounded
$value = $number;
$extension = '';
}
if ('common' == $method) {
$value = round($value, $precision);
} else {
if ('ceil' != $method && 'floor' != $method) {
throw new \RuntimeException('The number_to_human_readable filter only supports the "common", "ceil", and "floor" methods.');
}
$value = $method($value * pow(10, $precision)) / pow(10, $precision);
}
return $value.$extension;
}
|
php
|
{
"resource": ""
}
|
q240096
|
Grid._styleElement
|
train
|
protected function _styleElement()
{
$styleElementConfig = $this->gridConfig['styleElement'] ?? NULL;
if( ! empty($styleElementConfig) )
{
$attributes = NULL;
$sheet = Singleton::class('ZN\Hypertext\Sheet');
$style = Singleton::class('ZN\Hypertext\Style');
foreach( $styleElementConfig as $selector => $attr )
{
$attributes .= $sheet->selector($selector)->attr($attr)->create();
}
return $style->open().$attributes.$style->close();
}
return NULL;
}
|
php
|
{
"resource": ""
}
|
q240097
|
AbstractStateMachine._transition
|
train
|
protected function _transition($transition)
{
if (!$this->_canTransition($transition)) {
throw $this->_createCouldNotTransitionException(
$this->__('Cannot apply transition "%s"', $transition),
null,
null,
$transition
);
}
return $this->_applyTransition($transition);
}
|
php
|
{
"resource": ""
}
|
q240098
|
AbstractPhpEngine.loadTemplate
|
train
|
public function loadTemplate($template)
{
if (!$this->isLoaded($identity = $this->findIdentity($template))) {
if (!$this->supports($identity)) {
throw new \InvalidArgumentException(sprintf('Unsupported template "%s".', $identity->getName()));
}
$this->setLoaded($identity, $this->getLoader()->load($identity));
}
return $this->getLoaded($identity);
}
|
php
|
{
"resource": ""
}
|
q240099
|
DateTime.now
|
train
|
function now() {
if (strtolower($this->timeReference) == 'gmt') {
$now = time();
$system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
if (strlen($system_time) < 10) {
$system_time = time();
}
return $system_time;
} else {
return time();
}
}
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.