_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q238400 | Session.flash | train | public static function flash( $name, $string = '')
{
if( self::exists( $name ) )
{
$session = self::get( $name );
self::delete( $name );
return $session;
}else{
self::set( $name, $string );
}
return '';
} | php | {
"resource": ""
} |
q238401 | XmlDumper.addParameters | train | private function addParameters(\DOMElement $parent)
{
$data = $this->container->getParameterBag()->all();
if (!$data) {
return;
}
if ($this->container->isFrozen()) {
$data = $this->escape($data);
}
$parameters = $this->document->createElement... | php | {
"resource": ""
} |
q238402 | Expression.addArguments | train | public function addArguments(array $arguments)
{
foreach ($arguments as $param => $value) {
$this->addArgument($param, $value);
}
return $this;
} | php | {
"resource": ""
} |
q238403 | Expression.getArgument | train | public function getArgument($name)
{
if (isset($this->arguments[$name])) {
return $this->arguments[$name];
}
return null;
} | php | {
"resource": ""
} |
q238404 | KhipuRecipients.addRecipient | train | public function addRecipient($name, $email, $amount) {
if (count($this->recipients) == self::LIMIT_RECIPIENTS) {
// El servicio tiene un limite
return;
}
$this->recipients[] = array(
'name' => $name,
'email' => $email,
'amount' => $amount,
);
} | php | {
"resource": ""
} |
q238405 | Check.fileNoExtension | train | public static function fileNoExtension($file, $folder) {
if( is_array($file) )
return false;
$exts = new Extensions();
//case has extension
if( strstr($file, '.') && $exts->check($file) )
return false;
$files = self:... | php | {
"resource": ""
} |
q238406 | RegisterConfigFileProviderPass.addProvider | train | protected function addProvider(ContainerBuilder $container, $dir, $bundle)
{
if ($container->hasDefinition('integrated_solr.converter.config.provider.file.' . $bundle)) {
return null;
}
// If the bundle got a config/solr directory then a provider is created for this bundle. This... | php | {
"resource": ""
} |
q238407 | RegisterConfigFileProviderPass.addFinder | train | protected function addFinder(ContainerBuilder $container, $dir, $bundle)
{
$ref = new Reference('integrated_solr.converter.config.provider.file.' . $bundle . '.finder');
if ($container->hasDefinition('integrated_solr.converter.config.provider.file.' . $bundle . '.finder')) {
return $ref... | php | {
"resource": ""
} |
q238408 | MPDConnection.establish | train | public function establish() {
// Check whether the socket is already connected
if( isset($this->established) && $this->established ) {
return true;
}
// Try to open the socket connection to MPD with a 5 second timeout
if( !$th... | php | {
"resource": ""
} |
q238409 | MPDConnection.close | train | public function close() {
// Make sure nothing unexpected happens
try {
// Check that a connection exists first
if( isset( $this->socket ) ) {
// Close the socket
fclose( $this->socket );
// Unset the socket property
unset($this->so... | php | {
"resource": ""
} |
q238410 | MPDConnection.determineIfLocal | train | public function determineIfLocal() {
// Default it to false
$this->local = false;
// Compare the MPD host a few different ways to try and determine if it's local to the Apache server
if( ( stream_is_local( $this->socket )) ||
( $this->host == (isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : get... | php | {
"resource": ""
} |
q238411 | BrandController.showAction | train | public function showAction(Brand $brand)
{
$deleteForm = $this->createDeleteForm($brand);
return array(
'entity' => $brand,
'delete_form' => $deleteForm->createView(),
);
} | php | {
"resource": ""
} |
q238412 | BrandController.deleteAction | train | public function deleteAction(Request $request, Brand $brand)
{
$form = $this->createDeleteForm($brand);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($brand);
... | php | {
"resource": ""
} |
q238413 | BrandController.createDeleteForm | train | private function createDeleteForm(Brand $brand)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('ecommerce_brand_delete', array('id' => $brand->getId())))
->setMethod('DELETE')
->getForm()
;
} | php | {
"resource": ""
} |
q238414 | Rope.upperWords | train | public function upperWords($delimiters = " \t\r\n\f\v")
{
return static::of(
mb_ucwords($this->contents, $delimiters, $this->encoding),
$this->encoding
);
} | php | {
"resource": ""
} |
q238415 | Rope.beginsWith | train | public function beginsWith($prefix)
{
return $prefix === ''
|| mb_strpos(
$this->contents,
(string) $prefix,
null,
$this->encoding
) === 0;
} | php | {
"resource": ""
} |
q238416 | Rope.endsWith | train | public function endsWith($suffix)
{
return $suffix === ''
|| $suffix === mb_substr(
$this->contents,
-strlen((string) $suffix),
null,
$this->encoding
);
} | php | {
"resource": ""
} |
q238417 | Rope.contains | train | public function contains($inner)
{
return mb_strpos(
$this->contents,
(string) $inner,
null,
$this->encoding
) !== false;
} | php | {
"resource": ""
} |
q238418 | Rope.reverse | train | public function reverse()
{
return static::of(
ArrayList::of($this->split())->reverse()->join(),
$this->encoding
);
} | php | {
"resource": ""
} |
q238419 | Rope.concat | train | public function concat(...$others)
{
return static::of(
Std::foldl(
function ($carry, $part) {
return $carry . (string) $part;
},
$this->contents,
$others
),
$this->encoding
);
... | php | {
"resource": ""
} |
q238420 | Rope.equals | train | public function equals(Rope $other)
{
return $this->contents === $other->contents
&& $this->encoding === $other->encoding;
} | php | {
"resource": ""
} |
q238421 | SchemaDiscovery.getMessageDataSchema | train | public function getMessageDataSchema(MessageInterface $message): \stdClass
{
$parts = explode('.', $message->getPurpose());
if (empty($parts)) {
throw new InvalidMessageDataException('The message "purpose" property should clearly define specific message schema');
}
if (... | php | {
"resource": ""
} |
q238422 | RaInstaller.cleanUpOldModules | train | public static function cleanUpOldModules(Event $event)
{
$composer = $event->getComposer();
$requires = $composer->getPackage()->getRequires();
$projectPath = str_replace('vendor/vkf/shop', '', $composer->getInstallationManager()->getInstallpath($composer->getPackage()));
$modulePat... | php | {
"resource": ""
} |
q238423 | RaInstaller.getInstallPath | train | public function getInstallPath(PackageInterface $package)
{
if ($package->getType() === 'oxid-base') {
return $this->_locations[$package->getType()];
}
$themeName = "ra";
$extra = $package->getExtra();
$installFolder = $this->_locations[$package->getType()] . '/' ... | php | {
"resource": ""
} |
q238424 | Windows.notify | train | protected function notify($title, $message, $icon = null)
{
$app = __DIR__ . '/../../bin/toast.exe';
$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title);
$message = iconv('UTF-8', 'ASCII//TRANSLIT', $message);
$icon = is_string($icon) ? " -p \"$icon\"" : $this->icon;
$this... | php | {
"resource": ""
} |
q238425 | Cache.reset | train | public function reset(){
$originalSettings = $this->settings;
$this->settings = array();
if(file_put_contents($this->cacheFileName, "{}") === FALSE){
$this->settings = $originalSettings;
return FALSE;
}
return TRUE;
} | php | {
"resource": ""
} |
q238426 | WP_Url_Util.convert_absolute_path_to_url | train | function convert_absolute_path_to_url( $absolute_path ) {
// Remove WordPress installation path from file path.
$file_base = str_replace( ABSPATH, '', $absolute_path );
// Add site url to file base.
$file_url = trailingslashit( site_url() ) . $file_base;
return $file_url;
... | php | {
"resource": ""
} |
q238427 | WP_Url_Util.convert_url_to_absolute_path | train | function convert_url_to_absolute_path( $file_url ) {
// Remove WordPress site url from file url.
$file_base = str_replace( trailingslashit( site_url() ), '', $file_url );
// Add WordPress installation path to file base.
$absolute_path = ABSPATH . $file_base;
return $absolute_p... | php | {
"resource": ""
} |
q238428 | WP_Url_Util.is_external_file | train | public function is_external_file( $file_url ) {
// Set default return value.
$is_external_file = false;
// Parse url.
$parsed_file_url = parse_url( $file_url );
// Parse site url.
$parsed_site_url = parse_url( site_url() );
// Check if hosts don't match.
... | php | {
"resource": ""
} |
q238429 | WP_Url_Util.is_uploaded_file | train | public function is_uploaded_file( $file_url ) {
// Set default return value.
$is_uploaded_file = false;
// Get WordPress upload directory information.
$wp_upload_directory = wp_upload_dir();
// Check if the WordPress upload directory url matches the file url.
if ( fals... | php | {
"resource": ""
} |
q238430 | Builder.register | train | private function register() {
$this->options['labels'] = $this->label;
if (!isset($this->options['rewrite'])) {
$this->options['rewrite'] = array('slug' => $this->singular);
}
$_self = &$this;
add_action('init', function () use (&$_self) {
register_post_type($_self->singular, $_self->options);
});
... | php | {
"resource": ""
} |
q238431 | FormConditional.generate | train | public function generate(): string
{
$condID = (string)$this->attributes['data-conditional-id'];
$getState = $this->vHandler->get->get($condID.'_state', Variables::TYPE_INT) == 1;
$postState = $this->vHandler->post->get($condID.'_state', Variables::TYPE_INT) == 1;
$visible = $getStat... | php | {
"resource": ""
} |
q238432 | NormalizeArrayCapableTrait._normalizeArray | train | protected function _normalizeArray($value)
{
if ($value instanceof stdClass) {
$value = (array) $value;
}
if (is_array($value)) {
return $value;
}
if (!($value instanceof Traversable)) {
throw $this->_createInvalidArgumentException($this-... | php | {
"resource": ""
} |
q238433 | ErrorHandler.unstackErrors | train | public static function unstackErrors()
{
$level = array_pop(self::$stackedErrorLevels);
if (null !== $level) {
$errorReportingLevel = error_reporting($level);
if ($errorReportingLevel !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
// If ... | php | {
"resource": ""
} |
q238434 | Message.normalizeHeaderKey | train | public function normalizeHeaderKey(string $key)
{
$key = strtr(strtolower($key), '_', '-');
if (strpos($key, 'http-') === 0) {
$key = substr($key, 5);
}
return $key;
} | php | {
"resource": ""
} |
q238435 | Db._read | train | public function _read($pId)
{
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
}
if ($this->_items[$pId]->getId()) {
return $this->_items[$pId]->getData();
}
... | php | {
"resource": ""
} |
q238436 | Db._write | train | public function _write($pId, $pData)
{
Agl::validateParams(array(
'String' => $pData
));
$access = time();
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
... | php | {
"resource": ""
} |
q238437 | Db._destroy | train | public function _destroy($pId)
{
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
}
if ($this->_items[$pId]->getId()) {
$this->_items[$pId]->delete();
}
... | php | {
"resource": ""
} |
q238438 | Db._clean | train | public function _clean($pMax)
{
Agl::validateParams(array(
'Digit' => $pMax
));
$old = time() - $pMax;
$collection = new Collection(self::DB_COLLECTION);
$conditions = new Conditions();
$conditions->add('access', Conditions::LT, $old);
$collect... | php | {
"resource": ""
} |
q238439 | SomeCommandProvider.register | train | public function register(Application $App) {
$App->addCommand(new \YourApp\Command\Foo());
$App->addCommand(new \YourApp\Command\Bar());
$App->addCommand(new \YourApp\Command\Baz());
} | php | {
"resource": ""
} |
q238440 | PhpStore.prettyPrint | train | public static function prettyPrint($data, $prefix = '')
{
$php = '[' . PHP_EOL;
if (is_array($data) and array_diff_key($data, array_keys(array_keys($data)))) {
foreach ($data as $key => $value) {
$php .= $prefix . ' ' . var_export($key, true) . ' => ';
if... | php | {
"resource": ""
} |
q238441 | ExtensionHelper.renderPluginParams | train | public function renderPluginParams()
{
/** @var Extension $entity */
$tabNav = [];
$tabContent = [];
$entity = $this->_View->get('entity');
$params = Plugin::getData($entity->getName(), 'params');
foreach ($params->getArrayCopy() as $title => $_params) {
... | php | {
"resource": ""
} |
q238442 | TemplatingEngine.setEventDispatcher | train | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
$this->twig->setEventDispatcher($eventDispatcher);
} | php | {
"resource": ""
} |
q238443 | TemplatingEngine.addNamespace | train | public function addNamespace($namespace, $location)
{
$loader = $this->twig->getLoader();
$loader->addPath($location, $namespace);
foreach ($loader->getPaths() as $path) {
if (is_dir($dir = $path.'/'.$namespace)) {
$loader->prependPath($dir, $namespace);
}
}
} | php | {
"resource": ""
} |
q238444 | AbstractFileFinder._setCallbackFilter | train | protected function _setCallbackFilter($filter)
{
if (!is_callable($filter, true) && !is_null($filter)) {
throw new InvalidArgumentException('Filter must be a callable');
}
$this->callbackFilter = $filter;
return $this;
} | php | {
"resource": ""
} |
q238445 | AbstractFileFinder._getPaths | train | protected function _getPaths()
{
$directories = $this->_createDirectoryIterator($this->_getRootDir());
$flattened = $this->_createRecursiveIteratorIterator($directories);
$flattened->setMaxDepth($this->_getMaxDepth());
$filter = $this->_createFilterIterator($flattened, function (Sp... | php | {
"resource": ""
} |
q238446 | AbstractFileFinder._filterFile | train | protected function _filterFile(SplFileInfo $fileInfo)
{
if (!$fileInfo->isFile()) {
return false;
}
if (($expr = $this->_getFilenameRegex()) && !preg_match($expr, $fileInfo->getPathname())) {
return false;
}
if (($callback = $this->_getCallbackFilter... | php | {
"resource": ""
} |
q238447 | AssetFormulae.getOption | train | public function getOption($name)
{
if ($this->hasOption($name)) {
$option = $this->options[$name];
} else {
$option = null;
}
return $option;
} | php | {
"resource": ""
} |
q238448 | Whoops.loadWhoopsErrorHandler | train | protected function loadWhoopsErrorHandler()
{
$run = new \Whoops\Run;
$run->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$run->register();
return $run;
} | php | {
"resource": ""
} |
q238449 | Metas.addProperty | train | public function addProperty($property, $content, $position = 100)
{
$attr = [
'property' => $property,
'content' => $content
];
$this->add($attr, $position);
return $this;
} | php | {
"resource": ""
} |
q238450 | Metas.image | train | public function image($image, $position = 100)
{
$this->add(
[
'name' => 'image',
'property' => 'og:image',
'content' => $image
],
$position
);
$this->addElement(
$position,
$this->vo... | php | {
"resource": ""
} |
q238451 | GetValidationErrorsCapableCompositeTrait._getValidationErrors | train | protected function _getValidationErrors($subject)
{
$errors = array();
foreach ($this->_getChildValidators() as $_idx => $_validator) {
try {
if (!($_validator instanceof ValidatorInterface)) {
throw $this->_createOutOfRangeException($this->__('Validat... | php | {
"resource": ""
} |
q238452 | Time.secondToTime | train | static public function secondToTime($times)
{
$result = '00:00:00';
if ($times > 0) {
$hour = floor($times/3600);
$minute = floor(($times-3600 * $hour)/60);
$second = floor((($times-3600 * $hour) - 60 * $minute) % 60);
$result = str_pad($hour, 2, "0",... | php | {
"resource": ""
} |
q238453 | CheckerCollectionPresenter.display | train | public static function display(array $assocArgs, CheckerCollection $checkerCollection): void
{
// TODO: Use null coalescing assignment operator.
$assocArgs['fields'] = $assocArgs['fields'] ?? self::DEFAULT_FIELDS;
$formatter = new Formatter($assocArgs, $assocArgs['fields']);
$items ... | php | {
"resource": ""
} |
q238454 | CheckerCollectionPresenter.toArray | train | private static function toArray(CheckerCollection $checkerCollection): array
{
return array_map(function (CheckerInterface $checker): array {
return [
'id' => $checker->getId(),
'description' => $checker->getDescription(),
'link' => $checker->getLi... | php | {
"resource": ""
} |
q238455 | Query.modelInstance | train | private static function modelInstance(array $ctor = [])
{
static $cached;
if (!isset($cached)) {
$class = new ReflectionClass(get_called_class());
$cached = $class->newInstanceArgs($ctor);
}
return $cached;
} | php | {
"resource": ""
} |
q238456 | CORSHelper.handle | train | public function handle()
{
if(env('APP_ENV') == 'testing'){
return;
}
$this->origins();
$this->credentials();
$this->methods();
$this->headers();
} | php | {
"resource": ""
} |
q238457 | CORSHelper.origins | train | private function origins()
{
if(array_has($_SERVER, 'HTTP_ORIGIN')){
foreach (config('cors.origins') as $origin) {
if ($_SERVER['HTTP_ORIGIN'] == $origin) {
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
break;
... | php | {
"resource": ""
} |
q238458 | CORSHelper.methods | train | private function methods()
{
$methods = '';
foreach (config('cors.methods') as $method) {
$methods = $methods . $method . ', ';
}
header('Access-Control-Allow-Methods: ' . $methods);
} | php | {
"resource": ""
} |
q238459 | CORSHelper.headers | train | private function headers()
{
$headers = '';
foreach (config('cors.headers') as $header) {
$headers = $headers . $header . ', ';
}
header('Access-Control-Allow-Headers: ' . $headers);
} | php | {
"resource": ""
} |
q238460 | FnStream.decorate | train | public static function decorate(StreamInterface $stream, array $methods)
{
// If any of the required methods were not provided, then simply
// proxy to the decorated stream.
foreach (array_diff(static::SLOTS, array_keys($methods)) as $diff) {
$methods[$diff] = [$stream, $diff];
... | php | {
"resource": ""
} |
q238461 | TRouterConfiguration.configure | train | protected function configure(IConfig $config)
{
$configuration = $config->get('routes');
foreach ($configuration as $route)
{
$this->map($route);
}
} | php | {
"resource": ""
} |
q238462 | Arr.flattenAssoc | train | public static function flattenAssoc(
array $kvArray,
/*string*/ $kField,
/*string|boolean*/ $vField
) {
$array = [];
if(!empty($kvArray) && self::isAssoc($kvArray)) {
foreach($kvArray as $k => $v) {
$row = [];
if(is_string($vField)) {
$row[$vField] = $v;
} e... | php | {
"resource": ""
} |
q238463 | Performance.elapsed | train | public function elapsed(){
if(isset($this->timeBegin) && isset($this->timeEnd)){
return number_format($this->timeEnd - $this->timeBegin, 5);
}
else{
if(! isset($this->timeBegin)){
echo "It is necesary execute the method 'start' first";
}
... | php | {
"resource": ""
} |
q238464 | DetailedShow.setAkas | train | public function setAkas(array $akas)
{
$this->akas = [];
foreach ($akas as $aka) {
$this->addAka($aka);
}
return $this;
} | php | {
"resource": ""
} |
q238465 | Augmentor.augment | train | public function augment($data)
{
// initialize
$this[self::KEY_AUGMENTED] = [];
// get rules
$rulekeys = array_filter($this->keys(), function($key) {
return strpos($key, self::PREFIX_RULE) === 0;
});
// apply rules
foreach ($rulekeys as $rulename) ... | php | {
"resource": ""
} |
q238466 | Augmentor.getAugmentedSoFar | train | public function getAugmentedSoFar()
{
if (!$this->offsetExists(self::KEY_AUGMENTED)) {
$this[self::KEY_AUGMENTED] = [];
}
return $this[self::KEY_AUGMENTED];
} | php | {
"resource": ""
} |
q238467 | Augmentor.addRule | train | public function addRule($name, callable $rule)
{
if (isset($this[self::rule($name)])) {
throw new \RuntimeException("rule '$name' already exists'");
}
$this[self::rule($name)] = $this->protect($rule);
} | php | {
"resource": ""
} |
q238468 | Augmentor.appendTo | train | public function appendTo($key, $value)
{
if (!$this->offsetExists($key)) {
$this[$key] = [$value];
return;
}
$old_value = $this[$key];
if (!is_array($old_value)) {
$old_value = [$old_value];
}
if (is_array($value)) {
$ol... | php | {
"resource": ""
} |
q238469 | WorkerLogger.applyError | train | protected function applyError(
CacheItem $cacheItem,
$status,
$message,
$inputFilename,
$templateType,
$templateKey,
$logSeverity = 'error'
) {
$cacheItem
->setCacheStatus($status)
->setError($message);
$logger = $this-... | php | {
"resource": ""
} |
q238470 | PostalAddress.toString | train | public function toString()
{
return implode(', ', array_filter([
$this->name,
$this->street1,
$this->street2,
$this->city,
$this->county,
$this->postcode,
$this->country($this->country)->name,
]));
} | php | {
"resource": ""
} |
q238471 | AbstractFile.name | train | public function name($value = false, $overwrite = false)
{
if ($value === false) {
return $this->adapter->basename($this->path);
}
if (! is_string($value) || strlen($value) == 0) {
throw new FilesystemException('Invalid name given to name() method');
}
... | php | {
"resource": ""
} |
q238472 | AbstractFile.path | train | public function path($value = false, $overwrite = false)
{
if ($value === false) {
return $this->path;
}
$oldPath = $this->path;
if (!$overwrite && $this->adapter->fileExists($value)) {
throw new FilesystemException("Cannot rename the file '{$this->path}' to... | php | {
"resource": ""
} |
q238473 | AbstractFile.pathChanged | train | protected function pathChanged($oldPath)
{
foreach ($this->pathListeners as $cb) {
$cb($oldPath, $this->path);
}
} | php | {
"resource": ""
} |
q238474 | AbstractFile.perms | train | public function perms($value = false)
{
if ($value === false) {
return substr(sprintf('%o', $this->adapter->fileperms($this->path)), -4);
}
if (! $this->adapter->chmod($this->path, $value)) {
throw new FilesystemException("Unable to apply permissions to '{$this->path... | php | {
"resource": ""
} |
q238475 | AbstractFile.fs | train | public function fs()
{
if (null === $this->fs)
$this->fs = new Filesystem($this->getFilesystemPath(), $this->adapter);
return $this->fs;
} | php | {
"resource": ""
} |
q238476 | WebHookReceiver.validateAndParseWebhookNotificationFromCurrentRequest | train | public function validateAndParseWebhookNotificationFromCurrentRequest() {
// read the JSON input
$json_string = file_get_contents('php://input');
$json_data = json_decode($json_string, true);
// make sure the message is signed properly
// throws an exception if invalid
... | php | {
"resource": ""
} |
q238477 | WebHookReceiver.validateAndParseWebhookNotificationFromRequest | train | public function validateAndParseWebhookNotificationFromRequest(\Symfony\Component\HttpFoundation\Request $request) {
$json_data = json_decode($request->getContent(), true);
if (!is_array($json_data)) { throw new AuthorizationException("Invalid webhook data received"); }
// make sure the message... | php | {
"resource": ""
} |
q238478 | WebHookReceiver.validateWebhookNotification | train | public function validateWebhookNotification($json_data) {
// validate vars
if (!strlen($json_data['apiToken'])) { throw new AuthorizationException("API token not found"); }
if ($json_data['apiToken'] != $this->api_token) { throw new AuthorizationException("Invalid API token"); }
if (!str... | php | {
"resource": ""
} |
q238479 | Time.parseCompositeValue | train | protected function parseCompositeValue( $compositeValue )
{
$time = false;
try
{
$time = new RhubarbTime( $compositeValue );
}
catch( \Exception $er )
{
}
if( $time === false )
{
$this->model->hours = "";
$this->model->minutes = "";
}
else
{
$this->model->hours = $time->format( "H... | php | {
"resource": ""
} |
q238480 | Time.createCompositeValue | train | protected function createCompositeValue()
{
$hours = (int) $this->model->hours;
$minutes = (int) $this->model->minutes;
$time = new RhubarbTime();
$time->setTime( $hours, $minutes );
return $time;
} | php | {
"resource": ""
} |
q238481 | AssetExtension.asset | train | public function asset($asset, $version = null)
{
$host = $this->request->getHost();
$port = $this->request->getPort();
$path = $this->request->getBasePath();
if ('/' !== substr($asset, 1)) {
$asset = '/'.$asset;
}
if (80 === $port) {
$port = ... | php | {
"resource": ""
} |
q238482 | Store.set | train | public function set($key, $value) {
setvalr(trim($key), $this->data, $value);
return $value;
} | php | {
"resource": ""
} |
q238483 | Store.push | train | public function push($key, $data) {
$key = trim($key);
if (!array_key_exists($key, $this->data) || !is_array($this->data[$key])) {
$this->data[$key] = [];
}
array_push($this->data[$key], $data);
} | php | {
"resource": ""
} |
q238484 | AbstractCommand.addArgument | train | public function addArgument($argument, $description = null, $options = array(), \Closure $code = null)
{
return $this->addCommand($argument, $description, $options, $code);
} | php | {
"resource": ""
} |
q238485 | AbstractCommand.setOptions | train | public function setOptions($options)
{
$options = is_array($options) ? $options : array($options);
foreach ($options as $option)
{
$this->addOption($option);
}
return $this;
} | php | {
"resource": ""
} |
q238486 | AbstractCommand.renderAlternatives | train | public function renderAlternatives($wrongName, $exception)
{
/** @var $exception \InvalidArgumentException */
$message = $exception->getMessage();
$autoComplete = '';
$alternatives = array();
// Autocomplete
foreach ($this->children as $command)
{
/** @var $command Command */
$commandName = $... | php | {
"resource": ""
} |
q238487 | AppMetadata.offsetUnset | train | public function offsetUnset($key) {
$_key = $this->sql->real_escape_string($key);
if (!$this->sql->query("DELETE FROM `{$this->table}` WHERE `app` = '{$this->app}' AND `key` = '$_key'")) {
throw new AppMetadata_Exception(
"Unable to delete app metadata (`$_key`). {$this->sql->error}",
AppMetadata_Excepti... | php | {
"resource": ""
} |
q238488 | AppMetadata.buildDatabase | train | public function buildDatabase() {
if ($this->sql) {
if ($this->sql->query("
CREATE TABLE IF NOT EXISTS `{$this->table}` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`key` varchar(255) NOT NULL,
`value` text,
`validate` text,
`timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON U... | php | {
"resource": ""
} |
q238489 | AppMetadata.updateDerivedValues | train | private function updateDerivedValues($key = null, $value = null) {
/*
* TODO
* I darkly suspect that there is a possibility that you could create a loop
* of derived references that would be irresolvable and not currently detected
* e.g. A => '@B', B=>'@C', C=>'@A'. Perhaps the best approach would be ... | php | {
"resource": ""
} |
q238490 | AppMetadata.derivedValues | train | public function derivedValues($s) {
preg_match_all('/@(\w+)/', $s, $possibilities, PREG_SET_ORDER);
foreach ($possibilities as $possibility) {
if ($this->offsetExists($possibility[1]) && is_string($this->offsetGet($possibility[1]))) {
$s = str_replace($possibility[0], $this->offsetGet($possibility[1]), $s);
... | php | {
"resource": ""
} |
q238491 | Shop.getGoodsSN | train | public function getGoodsSN()
{
$step = 5000;
$start = 100;
$max = Goods::max('sn');
$max = count($max) && $max > $start ? $max : $start;
$sn = $max+1;
$sn_str = strval($sn);
if(str_contains($sn_str, '4')) {
$sn_str = str_replace('4', '5', $sn_str)... | php | {
"resource": ""
} |
q238492 | Shop.getOfferSN | train | public function getOfferSN()
{
$start = 5000;
$step = 5000;
$max = Offer::max('sn');
$max = count($max) && $max > $start ? $max : $start;
$sn = $max+1;
$sn_str = strval($sn);
if(str_contains($sn_str, '4')) {
$sn_str = str_replace('4', '5', $sn_str... | php | {
"resource": ""
} |
q238493 | OpenSSLCypher.encode | train | public function encode($data)
{
return openssl_encrypt($data, $this->method, $this->key, 0, $this->iv);
} | php | {
"resource": ""
} |
q238494 | OpenSSLCypher.decode | train | public function decode($data)
{
return openssl_decrypt($data, $this->method, $this->key, 0, $this->iv);
} | php | {
"resource": ""
} |
q238495 | DbImplement.initialize | train | public function initialize()
{
//throw exception if no database type has been set
if( ! $this->type )
{
//Throw exception
throw new DbException("Invalid database type provided");
}
//check the type of database provided returning instance
//set the parameter to check in switch clause
switch ($... | php | {
"resource": ""
} |
q238496 | ParsedownExtra.blockFencedCode | train | protected function blockFencedCode($line)
{
$regex = '/^([' . $line[ 'text' ][ 0 ] . ']{3,})[ ]*([\w-]+)?[ ]*$/';
if (preg_match($regex, $line[ 'text' ], $matches)) {
$element = [
'name' => 'code',
'text' => '',
];
if (isset($matc... | php | {
"resource": ""
} |
q238497 | ParsedownExtra.blockTable | train | protected function blockTable($line, array $block = null)
{
if (! isset($block) or isset($block[ 'type' ]) or isset($block[ 'interrupted' ])) {
return;
}
if (strpos($block[ 'element' ][ 'text' ], '|') !== false and chop($line[ 'text' ], ' -:|') === '') {
$alignments ... | php | {
"resource": ""
} |
q238498 | AbstractController.validate | train | protected function validate(array $rules, bool $throwError = true)
{
$validations = [];
$data = [];
foreach ($rules as $key => $rule) {
$value = $this->request->get($key);
$violations = $this->validator->validate($value, $rule);
if (count($violations) > 0)... | php | {
"resource": ""
} |
q238499 | AbstractController.auth | train | final protected function auth($member)
{
if ($member) {
$this->session->set('auth_member_id', $member->getId());
} else {
$this->session->remove('auth_member_id');
}
return $this;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.