_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q265600 | ActiveRecordModel.findAll | test | public function findAll()
{
$this->checkDb();
return $this->db->connect()
->select()
->from($this->tableName)
->execute()
->fetchAllClass(get_class($this));
} | php | {
"resource": ""
} |
q265601 | ActiveRecordModel.findAllWhere | test | public function findAllWhere($where, $value)
{
$this->checkDb();
$params = is_array($value) ? $value : [$value];
return $this->db->connect()
->select()
->from($this->tableName)
->where($where)
->execute($params)
->fetchAllClass(get_class($this));
} | php | {
"resource": ""
} |
q265602 | ActiveRecordModel.create | test | protected function create()
{
$this->checkDb();
$properties = $this->getProperties();
unset($properties[$this->tableIdColumn]);
$columns = array_keys($properties);
$values = array_values($properties);
$this->db->connect()
->insert($this->tableName, $columns)
->execute($values);
$this->{$this->tableIdColumn} = $this->db->lastInsertId();
} | php | {
"resource": ""
} |
q265603 | ActiveRecordModel.updateWhere | test | protected function updateWhere($where, $value)
{
$this->checkDb();
$properties = $this->getProperties();
$columns = array_keys($properties);
$values = array_values($properties);
$values1 = is_array($value)
? $value
: [$value];
$values = array_merge($values, $values1);
$this->db->connect()
->update($this->tableName, $columns)
->where($where)
->execute($values);
} | php | {
"resource": ""
} |
q265604 | Pattern.parseNotation | test | protected function parseNotation($notation)
{
$out = str_replace(['[', ']'], ['(?:', ')?'], $notation);
$enhancement = '(?P<\2>' . self::REGVAL . ')';
$out = preg_replace(self::REGKEY, $enhancement, $out);
return $out;
} | php | {
"resource": ""
} |
q265605 | Pattern.applyConditions | test | protected function applyConditions($expression, $conditions)
{
$search = $replace = [];
foreach ($conditions as $key => $value) {
$search[] = "<$key>" . self::STRVAL;
$replace[] = "<$key>$value";
}
return str_replace($search, $replace, $expression);
} | php | {
"resource": ""
} |
q265606 | Mean.calculate | test | public function calculate(): FormulasInterface
{
if (! $this->dataSet instanceof DataSet) {
throw new WrongUsageException('DataSet was not provided for mean calculus');
}
$dataSetSize = $this->dataSet->getSize();
$this->result = [];
foreach ($this->dataSet as $instance) {
foreach ($instance->getDimensions() as $index => $dimension) {
$this->result[0][$index] = $this->result[0][$index] ?? 0;
$this->result[0][$index] += $dimension / $dataSetSize;
}
foreach ($instance->getOutputs() as $index => $output) {
$this->result[1][$index] = $this->result[1][$index] ?? 0;
$this->result[1][$index] += $output / $dataSetSize;
}
}
return $this;
} | php | {
"resource": ""
} |
q265607 | HttpClientFactory.create | test | public function create(HttpClient $client = null): PluginClient
{
return new PluginClient($client ?? HttpClientDiscovery::find(), $this->plugins);
} | php | {
"resource": ""
} |
q265608 | BinaryFileResponse.setFile | test | public function setFile($file, $contentDisposition = null, $etag = false, $lastModified = true)
{
if (!$file instanceof File) {
if ($file instanceof \SplFileInfo) {
$file = new File($file->getPathname());
} else {
$file = new File((string) $file);
}
}
if (!$file->isReadable()) {
throw new FileException('File must be readable.');
}
$this->file = $file;
if ($etag === true)
$this->setAutoEtag();
elseif (!empty($etag))
$this->setEtag($etag);
if ($lastModified === true)
$this->setAutoLastModified();
elseif (!empty($lastModified))
{
is_numeric($lastModified) && $lastModified = '@'.$lastModified;
$this->setLastModified(new \DateTime($lastModified));
}
if ($contentDisposition)
$this->setContentDisposition($contentDisposition);
return $this;
} | php | {
"resource": ""
} |
q265609 | RemoteLoader.addTemplate | test | public function addTemplate($name, $url, $ttl, array $blocks, array $metadata)
{
$this->templates[$name] = [
'url' => $url,
'ttl' => $ttl,
'blocks' => $blocks,
'metadata' => $metadata,
'checked_ttl' => false,
'checking_ttl' => false,
];
} | php | {
"resource": ""
} |
q265610 | RemoteLoader.checkCacheFileTtl | test | private function checkCacheFileTtl($name)
{
// this method is called only if env->isAutoReload() == FALSE
if (
false !== ($cacheFile = $this->container->get('twig')->getCacheFilename($name))
&& \is_file($cacheFile)
&& \time() - \filemtime($cacheFile) >= $this->templates[$name]['ttl']
) {
// remove expired cache file
\unlink($cacheFile);
}
} | php | {
"resource": ""
} |
q265611 | RemoteLoader.placeholdersToBlocks | test | private function placeholdersToBlocks(array $blocks, $source)
{
$usedBlockMap = [];
$placeholderToBlockMap = [];
$pattern = '';
$first = true;
foreach ($blocks as $blockName => $block) {
$first ? $first = false : $pattern .= '|';
$pattern .= \preg_quote($block['placeholder'], '/');
$placeholderToBlockMap[$block['placeholder']] = $blockName;
}
return \preg_replace_callback(
\sprintf('/(%s)/', $pattern),
function (array $match) use ($placeholderToBlockMap, &$usedBlockMap) {
$blockName = $placeholderToBlockMap[$match[0]];
if (isset($usedBlockMap[$blockName])) {
return $this->createRepeatedPlaceholderBlockSyntax($blockName);
}
$usedBlockMap[$blockName] = true;
return $this->createPlaceholderBlockSyntax($blockName);
},
$source
);
} | php | {
"resource": ""
} |
q265612 | RemoteLoader.getMetadata | test | private function getMetadata($name)
{
$this->ensureExists($name);
return
['url' => $this->templates[$name]['url']]
+ $this->templates[$name]['metadata'];
} | php | {
"resource": ""
} |
q265613 | YamlDefinitionLoaderFactory.buildDefinitionProvider | test | public static function buildDefinitionProvider(Discovery $discovery)
{
$bindings = $discovery->findBindings('definition-interop/yaml-definition-files');
$definitionProviders = [];
foreach ($bindings as $binding) {
foreach ($binding->getResources() as $resource) {
/* @var $resource FileResource */
$definitionProviders[] = new YamlDefinitionLoader($resource->getFilesystemPath());
}
}
return self::mergeDefinitionProviders($definitionProviders);
} | php | {
"resource": ""
} |
q265614 | FormulasResults.of | test | public function of(string $formulaName)
{
if (! isset($this->results[$formulaName])) {
throw new CalculusResultNotFound('No result found for the given formula : ' . $formulaName );
}
return $this->results[$formulaName];
} | php | {
"resource": ""
} |
q265615 | FormulasResults.save | test | public function save(FormulasInterface $formula): FormulasResults
{
if ($this->isValid($formula)) {
$this->results[get_class($formula)] = $formula->getResult();
}
//the stack contains all the formulas called (a callstack)
$this->stack[] = $formula;
return $this;
} | php | {
"resource": ""
} |
q265616 | Helper.addHeader | test | public function addHeader(ItemInterface $item, $text)
{
return $item->addChild('header_' . \rand())
->setLabel($text)
->setAttribute('class', 'nav-header');
} | php | {
"resource": ""
} |
q265617 | Helper.setDropdown | test | public function setDropdown(ItemInterface $dropDownItem)
{
$dropDownItem
->setUri('#')
->setLinkattribute('class', 'dropdown-toggle')
->setLinkattribute('data-toggle', 'dropdown')
->setAttribute('class', 'dropdown')
->setChildrenAttribute('class', 'dropdown-menu');
$dropDownItem->setLabel($dropDownItem->getLabel() . '<b class="caret"></b>');
$dropDownItem->setExtra('safe_label', true);
} | php | {
"resource": ""
} |
q265618 | Helper.isUserGranted | test | public function isUserGranted($attributes, $subject = null): bool
{
return $this->security->isGranted($attributes, $subject);
} | php | {
"resource": ""
} |
q265619 | ResponseFactory.download | test | public function download($file, $name = null, array $headers = [], $options = [], $disposition = 'attachment')
{
!empty($options['cached']) && $headers = array_merge($headers, ['Cache-Control' => 'private, max-age=3600, must-revalidate', 'Pragma' => 'cache']);
!empty($options['mime_type']) && $headers = array_merge($headers, ['Content-Type' => $options['mime_type']]);
$response = new BinaryFileResponse($file, 200, $headers, true, $disposition);
if (isset($options['last_modified']))
$response->setLastModified($options['last_modified']);
if (isset($options['etag']))
$response->setEtag($options['etag']);
if (!is_null($name))
$response->setContentDisposition($disposition, $name, str_replace('%', '', Str::ascii($name)));
return $response;
} | php | {
"resource": ""
} |
q265620 | YandexAdapter.getUrl | test | private function getUrl($type, $key)
{
switch ($type) {
case 'album':
$url = 'album/%s/';
break;
case 'photo':
$url = 'photo/%s/';
break;
case 'albumPhotos':
$url = 'album/%s/photos/';
break;
case 'albums':
$url = 'albums/';
break;
case 'tags':
$url = 'tags/';
break;
case 'tag':
$url = 'tag/%s/photos/';
break;
default:
$url = '/';
}
return sprintf($url, $key);
} | php | {
"resource": ""
} |
q265621 | YandexAdapter.setListCover | test | private function setListCover(array $listCover, Gallery $album)
{
foreach ($listCover as $image) {
$album->addCover(new Meta($image['href'], $image['width'], $image['height']));
}
} | php | {
"resource": ""
} |
q265622 | YandexAdapter.getDataByType | test | private function getDataByType($key, $type = 'photo')
{
$url = $this->getUrl($type, $key);
return $this->getData($url);
} | php | {
"resource": ""
} |
q265623 | YandexAdapter.getData | test | private function getData($url)
{
try {
$request = $this->client->get($url);
$response = $request->send();
$decoder = new JsonDecode(true);
$data = $decoder->decode($response->getBody(true), 'json');
if (isset($data['links']['next'])) {
$next = $this->getData($data['links']['next']);
$data['entries'] = array_merge($data['entries'], $next['entries']);
}
} catch (\Exception $e) {
$data = array();
}
return $data;
} | php | {
"resource": ""
} |
q265624 | RouteInstaller.install | test | public static function install($baseUri = null) {
$baseUri = $baseUri ? "$baseUri/" : "";
\Route::post($baseUri . "resources/bulk/{resource}", "Foothing\RepositoryController\Controllers\ResourceController@postBulk");
\Route::put($baseUri . "resources/bulk/{resource}", "Foothing\RepositoryController\Controllers\ResourceController@putBulk");
\Route::put($baseUri . "resources/{resource}/{id}/link/{relation}/{related}/{relatedId}", "Foothing\RepositoryController\Controllers\ResourceController@putLink");
\Route::delete($baseUri . "resources/{resource}/{id}/link/{relation}/{related}/{relatedId}", "Foothing\RepositoryController\Controllers\ResourceController@deleteLink");
\Route::get($baseUri . "resources/{resource}/{id?}/{args?}", "Foothing\RepositoryController\Controllers\ResourceController@getIndex")->where('args', '[a-zA-Z0-9/_]*');
\Route::put($baseUri . "resources/{resource}/{id}", "Foothing\RepositoryController\Controllers\ResourceController@putIndex");
\Route::delete($baseUri . "resources/{resource}/{id}", "Foothing\RepositoryController\Controllers\ResourceController@deleteIndex");
\Route::post($baseUri . "resources/{resource}", "Foothing\RepositoryController\Controllers\ResourceController@postIndex");
} | php | {
"resource": ""
} |
q265625 | DocParser.isValidDate | test | private function isValidDate($date){
return preg_match('#[0-3][0-9]\/[0-1][0-9]\/[2][0][0-9][0-9]#', $date)
&&
checkdate((int)substr($date, 3, 2),
(int)substr($date, 0, 2),
(int)substr($date, 6, 4));
} | php | {
"resource": ""
} |
q265626 | pxcmd.wrap_gui_frame | test | public function wrap_gui_frame( $content ){
$this->bowl()->send($content);
unset($content);
@header( 'Content-type: text/html; charset="UTF-8"' );
// リソースをキャッシュ領域にコピー
$path_pxcache = $this->px->fs()->get_realpath( $this->px->get_path_controot().$this->px->conf()->public_cache_dir.'/px/' );
$realpath_pxcache = $this->px->fs()->get_realpath( $this->px->get_realpath_docroot().$path_pxcache );
$this->px->fs()->mkdir( $realpath_pxcache );
$this->px->fs()->copy_r( __DIR__.'/files/', $realpath_pxcache );
$pxcmd = $this->px->get_px_command();
ob_start();?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title><?= htmlspecialchars( $this->px->conf()->name ) ?></title>
<!-- jQuery -->
<script src="<?= htmlspecialchars( $path_pxcache.'scripts/jquery-1.10.1.min.js' ); ?>" type="text/javascript"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="<?= htmlspecialchars( $path_pxcache.'styles/bootstrap/css/bootstrap.min.css' ); ?>">
<script src="<?= htmlspecialchars( $path_pxcache.'styles/bootstrap/js/bootstrap.min.js' ); ?>"></script>
<!-- FESS -->
<link rel="stylesheet" href="<?= htmlspecialchars( $path_pxcache.'styles/contents.css' ); ?>" type="text/css" />
<!-- layout -->
<link rel="stylesheet" href="<?= htmlspecialchars( $path_pxcache.'styles/layout.css' ); ?>" type="text/css" />
<?= $this->bowl()->pull('head') ?>
</head>
<body class="pxcmd">
<div class="pxcmd-outline">
<div class="pxcmd-pxfw clearfix">
<div class="pxcmd-pxfw_l"><?= $this->px->get_pickles_logo_svg() ?> Pickles 2 (version: <?= htmlspecialchars( $this->px->get_version() ) ?>)</div>
<div class="pxcmd-pxfw_r">
<?php
// $pxcommands = $this->pxcommands;
// if( count($pxcommands) ){
// print '<select onchange="window.location.href=\'?PX=\'+this.options[this.selectedIndex].value;">';
// foreach( $pxcommands as $row ){
// print '<option value="'.htmlspecialchars($row['cmd']).'"'.($row['cmd']==$pxcmd[0]?' selected="selected"':'').'>'.htmlspecialchars($row['name']).'</option>';
// }
// print '</select>';
// }
?>
</div>
</div><!-- /.pxcmd-pxfw -->
<div class="pxcmd-header">
<div class="pxcmd-project_title"><?= htmlspecialchars( @$this->px->conf()->name ) ?></div>
</div><!-- /.pxcmd-header -->
<div class="pxcmd-middle">
<?php
$command_title = $pxcmd[0].(@strlen($pxcmd[1])?'.'.$pxcmd[1]:'');
$page_title = null;
?>
<div class="pxcmd-title">
<?php if(strlen($page_title)){ ?>
<p class="pxcmd-category_title"><a href="?PX=<?= htmlspecialchars( $command_title ) ?>" style="color:inherit; text-decoration:none;"><?= htmlspecialchars($command_title) ?></a></p>
<h1><?= htmlspecialchars( $page_title ) ?></h1>
<?php }else{ ?>
<h1><a href="?PX=<?= htmlspecialchars( $command_title ) ?>" style="color:inherit; text-decoration:none;"><?= htmlspecialchars( $command_title ) ?></a></h1>
<?php } ?>
</div><!-- /.pxcmd-title -->
<div id="content" class="contents">
<?= $this->bowl()->pull() ?>
</div>
</div><!-- /.pxcmd-middle -->
<div class="pxcmd-footer">
<p><a href="?" class="btn btn-default">PX Commands を終了する</a></p>
<p>PHP <?= htmlspecialchars(phpversion()) ?></p>
<p><?= htmlspecialchars(@date('Y-m-d H:i:s')) ?></p>
<p class="pxcmd-credits"><a href="http://pickles.pxt.jp/" target="_blank">Pickles Framework</a> (C)Tomoya Koyanagi.</p>
</div><!-- /.footer -->
</div>
</body>
</html>
<?php
return ob_get_clean();
} | php | {
"resource": ""
} |
q265627 | Kernel.run | test | public function run($commandline)
{
$this->bootstrap();
$artisan = $this->getArtisan();
$artisan->setCatchExceptions(false);
$artisan->run($input = new \Symfony\Component\Console\Input\StringInput(trim(str_replace('php artisan', '', $commandline))), $out = new \Symfony\Component\Console\Output\BufferedOutput);
$artisan->setCatchExceptions(true);
return $out;
} | php | {
"resource": ""
} |
q265628 | ReflectionMethod.factory | test | public static function factory($class, $method = null)
{
if (is_object($class))
$class = get_class($class);
$class = (string)$class;
if (!isset(self::$methods[$class])) {
$classReflection = new \ReflectionClass($class);
$methods = $classReflection->getMethods();
self::$methods[$class] = array();
foreach ($methods as $methodReflection) {
if ($methodReflection->class != $class) {
self::$methods[$class][$methodReflection->name] = self::factory($methodReflection->class, $methodReflection->name);
} else {
self::$methods[$class][$methodReflection->name] = new self($class, $methodReflection->name);
self::$methods[$class][$methodReflection->name]->setAccessible(true);
}
}
}
if (isset($method)) {
if (!isset(self::$methods[$class][$method])) {
self::$methods[$class][$method] = new self($class, $method);
self::$methods[$class][$method]->setAccessible(true);
}
return self::$methods[$class][$method];
} else
return array_values(self::$methods[$class]);
} | php | {
"resource": ""
} |
q265629 | RedisDriver.createSession | test | function createSession(SessionManager $sessionManager, $userProfile = null)
{
$sessionLifeTime = $sessionManager->getSessionConfig()->getLifetime();
$initialData = [];
$profiles = [];
if ($userProfile) {
$profiles = [$userProfile];
}
$initialData['profiles'] = $profiles;
$initialData['data'] = [];
$dataString = $this->serializer->serialize($initialData);
$lockToken = null;
for ($count = 0; $count < 10; $count++) {
$sessionId = $this->idGenerator->generateSessionID();
$lockToken = $this->acquireLockIfRequired($sessionId, $sessionManager);
$dataKey = generateSessionDataKey($sessionId);
$set = $this->redisClient->set(
$dataKey,
$dataString,
'EX',
$sessionLifeTime,
'NX'
);
if ($set) {
return new RedisSession(
$sessionId,
$this,
$sessionManager,
[],
$profiles,
false,
$lockToken
);
}
if ($lockToken !== null) {
$this->releaseLock($sessionId, $lockToken);
}
}
throw new AsmException(
"Failed to createSession.",
AsmException::ID_CLASH
);
} | php | {
"resource": ""
} |
q265630 | Agent.sendEntity | test | private function sendEntity($entity_name, array $data, $key_id)
{
$client = $this->getClient();
$this->getLogger()->info('Sending new ' . $entity_name . '.');
try {
$this->getLogger()->info('Try to PUT data to existing ' . $entity_name . ' record.');
$data[$key_id . '_uri'] = $data[$key_id];
$client->getCommand('put' . $entity_name, $data)
->execute();
} catch (ClientErrorResponseException $e) {
if ($e->getResponse()->getStatusCode() === 404) {
// The server doesn't exist yet. We need to POST it.
$this->getLogger()->info($entity_name . ' was not found on PUT request. Doing POST to create it.');
$client->getCommand('post' . $entity_name, $data)
->execute();
} else {
// This is not a 404 error, throw the exception.
throw $e;
}
}
$this->getLogger()->info('The ' . $entity_name . ' information has been successfully sent.');
} | php | {
"resource": ""
} |
q265631 | ProviderFacter.registerProviders | test | public function registerProviders()
{
$finder = new Finder();
$finder->files()
->ignoreUnreadableDirs()
->in($this->providers_dir)
->sortByName()
->name('*.php');
foreach ($finder as $provider) {
$this->registerProviderFromFile($provider);
}
} | php | {
"resource": ""
} |
q265632 | ProviderFacter.registerProviderFromFile | test | public function registerProviderFromFile(\SplFileInfo $provider_file)
{
$class_name = $this->providers_namespace . '\\' . $provider_file->getBasename('.php');
$this->addProvider($this->factory($class_name));
} | php | {
"resource": ""
} |
q265633 | ProviderFacter.getFacts | test | public function getFacts($cached = true)
{
if (is_null($this->facts)) {
$this->populateFacts();
}
return $this->facts;
} | php | {
"resource": ""
} |
q265634 | ProviderFacter.populateFacts | test | public function populateFacts()
{
$this->facts = array();
foreach ($this->providers as $provider) {
$this->facts = array_replace_recursive($this->facts, $provider->getFacts());
}
} | php | {
"resource": ""
} |
q265635 | EventSourcedAggregateRoot.record | test | private function record($domainEvent)
{
$this->ensureChangesEventStream();
$this->changes = $this->changes->append($domainEvent);
} | php | {
"resource": ""
} |
q265636 | EventSourcedAggregateRoot.apply | test | public function apply($domainEvent)
{
$domainEvent = $this->ensureDomainEvent($domainEvent);
$eventHandlerName = $this->getEventHandlerName($domainEvent);
if (method_exists($this, $eventHandlerName)) {
$this->executeEventHandler($this, $eventHandlerName, $domainEvent);
} else {
$this->applyRecursively($eventHandlerName, $domainEvent);
}
} | php | {
"resource": ""
} |
q265637 | px.fnc_call_plugin_funcs | test | private function fnc_call_plugin_funcs( $func_list ){
if( is_null($func_list) ){ return false; }
$param_arr = func_get_args();
array_shift($param_arr);
if( @!empty( $func_list ) ){
// functions
if( is_object($func_list) ){
$func_list = get_object_vars( $func_list );
}
if( is_string($func_list) ){
$fnc_name = $func_list;
$fnc_name = preg_replace( '/^\\\\*/', '\\', $fnc_name );
$option_value = null;
preg_match( '/^(.*?)(?:\\((.*)\\))?$/s', $fnc_name, $matched );
if(array_key_exists( 1, $matched )){
$fnc_name = @$matched[1];
}
if(array_key_exists( 2, $matched )){
$option_value = @$matched[2];
}
unset($matched);
if( strlen( trim($option_value) ) ){
$option_value = json_decode( $option_value );
}else{
$option_value = null;
}
// var_dump($fnc_name);
// var_dump($option_value);
$this->proc_num ++;
if( @!strlen($this->proc_id) ){
$this->proc_id = $this->proc_type.'_'.$this->proc_num;
}
array_push( $param_arr, $option_value );
call_user_func_array( $fnc_name, $param_arr);
$this->proc_id = null;
}elseif( is_array($func_list) ){
foreach( $func_list as $fnc_id=>$fnc_name ){
if( is_string($fnc_name) ){
$fnc_name = preg_replace( '/^\\\\*/', '\\', $fnc_name );
}
if( is_string($fnc_id) && !preg_match('/^[0-9]+$/', $fnc_id) ){
$this->proc_id = $fnc_id;
}
$param_arr_dd = $param_arr;
array_unshift( $param_arr_dd, $fnc_name );
call_user_func_array( array( $this, 'fnc_call_plugin_funcs' ), $param_arr_dd);
}
}
unset($fnc_name);
}
return true;
} | php | {
"resource": ""
} |
q265638 | BarTable.draw | test | public function draw($data) {
// if the data is sane, and the widths have been set (if not calculate them)
if ($this->dataCheck($data)) {
$barStyle = new Style();
// set the colors to the bar text and fill
$barStyle->setColors($this->barText, $this->barFill);
$bodyStyle = new Style();
// set the colors to the body text and fill
$bodyStyle->setColors($this->bodyText, $this->bodyFill);
// calculate the widths
$this->calculateWidths($data);
// calculate the total width
$totalWidth = $this->calcTotalWidth();
// if at least one of the columns has header text
if ($this->hasHeader()) {
$headers = $this->getHeaderText();
// if a title was specified
if ($this->title) {
// center the title
$justifiedText = $this->clio->justify($this->title, "center", $totalWidth);
// create a title style
$titleStyle = new Style();
$titleStyle->setBold()->setTextColor($this->bodyText);
// ask Clio to draw it
$this->clio->style($titleStyle)->display($justifiedText)->clear()->newLine();
}
// draw the row of cells
$this->drawRow($headers, $barStyle);
}
// go through each row of data
for ($row = 0; $row<count($data); ++$row) {
// draw the row of cells
$this->drawRow($data[$row], $bodyStyle);
}
// if the last line is desired
if ($this->showBottomLine) {
// now add an empty line
$emptyLine = str_pad("",$totalWidth);
// underline it to create a bottom line with the bar fill
$underline = (new Style())->setUnderscore()->setColors($this->barFill, $this->bodyFill);
// ask Clio to display it
$this->clio->style($underline)->display($emptyLine);
}
}
} | php | {
"resource": ""
} |
q265639 | Calculator.calculate | test | public function calculate(FormulasInterface $formula): Calculator
{
$formula
->using($this->dataSet)
->knowing($this->results)
->calculate();
$this->results->save($formula);
return $this;
} | php | {
"resource": ""
} |
q265640 | LayoutHelper.hasLayout | test | public function hasLayout()
{
$masterRequest = $this->requestStack->getMasterRequest();
$currentRequest = $this->requestStack->getCurrentRequest();
if (
$masterRequest->isXmlHttpRequest()
|| 'off' === $masterRequest->get('_layout')
|| (
$currentRequest !== $masterRequest
&& !$currentRequest->attributes->has('exception')
&& !$currentRequest->attributes->get('_layout', false)
)
) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q265641 | Style.initialize | test | public function initialize(TerminalStateInterface $state) {
// both bold and underscore will have a value of true or false (not undefined
$this->setBold($state->isBold());
$this->setUnderscore($state->isUnderscore());
// for colors, if the color is not valid, then it will stay undefined in this context
// get the text color
$textColor = $state->getTextColor();
// if the text color is valid
if ($textColor->isValid()) {
// set it
$this->setTextColor($textColor);
} else {
// the text color is not valid, null out the text color
$this->setTextColor(null);
}
// get the fill color
$fillColor = $state->getFillColor();
// if the fill color is valid
if ($fillColor->isValid()) {
// set it
$this->setFillColor($fillColor);
} else {
// the fill color is not valid, null out the fill color
$this->setFillColor(null);
}
// chaining
return $this;
} | php | {
"resource": ""
} |
q265642 | Style.overrideMembersTo | test | public function overrideMembersTo(StyleInterface $style) {
// text color
$styleTextColor = $style->getTextColor();
// only change if there is a text color set
if ($styleTextColor) {
// clone the text color
$this->textColor = clone $styleTextColor;
}
// fill color
$styleFillColor = $style->getFillColor();
// only change if there is a fill color set
if ($styleFillColor) {
// clone the fill color
$this->fillColor = clone $styleFillColor;
}
// font styling
// get the overriding bold
$bold = $style->getBold();
// only change the bold, if it is set to something
if (!is_null($bold)) {
// save the new bold state
self::setBold($bold);
}
// get the overriding underscore
$underscore = $style->getUnderscore();
// only change the underscore, if it is set to something
if (!is_null($underscore)) {
// save the new underscore state
self::setUnderscore($underscore);
}
// chaining
return $this;
} | php | {
"resource": ""
} |
q265643 | Style.clearStyling | test | public function clearStyling() {
// reset the colors to null
$this->textColor = $this->fillColor = null;
// reset the underscore and bold to false
$this->underscore = $this->bold = null;
// chaining
return $this;
} | php | {
"resource": ""
} |
q265644 | Style.setTextColor | test | public function setTextColor($color) {
// if it is null, just remember null
if (is_null($color)) {
// undefined
$this->textColor = null;
// it is an instance of Color
} elseif ($color instanceof Color) {
// clone it
$this->textColor = clone $color;
// it is some other type
} else {
// let the Color object sort it out
$this->textColor = new Color($color);
}
// chaining
return $this;
} | php | {
"resource": ""
} |
q265645 | Style.setFillColor | test | public function setFillColor($color) {
// if it is null, just remember null
if (is_null($color)) {
// undefined
$this->fillColor = null;
// if it is an instance of a color
} elseif ($color instanceof Color) {
// clone it
$this->fillColor = clone $color;
} else
{
// it is something else, let the Color object sort it out
$this->fillColor = new Color($color);
}
// chaining
return $this;
} | php | {
"resource": ""
} |
q265646 | Style.setColors | test | public function setColors($textColor, $fillColor) {
// set the text color
self::setTextColor($textColor);
// set the fill color
self::setFillColor($fillColor);
// chaining
return $this;
} | php | {
"resource": ""
} |
q265647 | Style.reverseColors | test | public function reverseColors() {
// switch them
$text = $this->textColor;
$this->textColor = $this->fillColor;
$this->fillColor = $text;
return $this;
} | php | {
"resource": ""
} |
q265648 | ReflectionFunction.factory | test | public static function factory($function)
{
$function = (string)$function;
if (!isset(self::$functions[$function]))
self::$functions[$function] = new self($function);
return self::$functions[$function];
} | php | {
"resource": ""
} |
q265649 | Autoloader.loadPlugins | test | public function loadPlugins()
{
$this->checkCache();
$this->validatePlugins();
$this->countPlugins();
foreach (self::$cache['plugins'] as $plugin_file => $plugin_info) {
include_once(WPMU_PLUGIN_DIR . '/' . $plugin_file);
}
$this->pluginHooks();
} | php | {
"resource": ""
} |
q265650 | Autoloader.showInAdmin | test | public function showInAdmin($show, $type)
{
$screen = get_current_screen();
$current = is_multisite() ? 'plugins-network' : 'plugins';
if ($screen->{'base'} != $current || $type != 'mustuse' || !current_user_can('activate_plugins')) {
return $show;
}
$this->updateCache();
self::$auto_plugins = array_map(function ($auto_plugin) {
return $auto_plugin;
}, self::$auto_plugins);
$GLOBALS['plugins']['mustuse'] = array_unique(array_merge(self::$auto_plugins, self::$mu_plugins), SORT_REGULAR);
return false;
} | php | {
"resource": ""
} |
q265651 | Autoloader.checkCache | test | private function checkCache()
{
$cache = get_site_option('bedrock_autoloader');
if ($cache === false) {
$this->updateCache();
return;
}
self::$cache = $cache;
} | php | {
"resource": ""
} |
q265652 | Autoloader.updateCache | test | private function updateCache()
{
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
self::$auto_plugins = get_plugins(self::$relative_path);
self::$mu_plugins = get_mu_plugins();
$plugins = array_diff_key(self::$auto_plugins, self::$mu_plugins);
$rebuild = !is_array(self::$cache['plugins']);
self::$activated = ($rebuild) ? $plugins : array_diff_key($plugins, self::$cache['plugins']);
self::$cache = array('plugins' => $plugins, 'count' => $this->countPlugins());
update_site_option('bedrock_autoloader', self::$cache);
} | php | {
"resource": ""
} |
q265653 | Autoloader.pluginHooks | test | private function pluginHooks()
{
if (!is_array(self::$activated)) {
return;
}
foreach (self::$activated as $plugin_file => $plugin_info) {
add_action('wp_loaded', function () use ($plugin_file) {
do_action('activate_' . $plugin_file);
});
}
} | php | {
"resource": ""
} |
q265654 | Multilog.channel | test | public function channel($name)
{
if (array_key_exists($name, $this->channels)) {
return $this->channels[$name];
}
return null;
} | php | {
"resource": ""
} |
q265655 | Multilog.initLoggers | test | private function initLoggers(array $loggers)
{
foreach ($loggers as $channel => $config) {
$this->createLogger($channel, $config);
}
} | php | {
"resource": ""
} |
q265656 | Multilog.createLogger | test | private function createLogger($channel, array $config)
{
// Setup configuration
// Use default laravel logs path
$storagePath = $this->app->make('path.storage');
$filepath = $storagePath . '/logs/' . $config['stream'];
$logger = new Logger($channel);
$handler = new StreamHandler($filepath);
// Daily rotation
if ($config['daily']) {
$handler = new RotatingFileHandler($filepath, 1);
}
// Format line
if (isset($config['format'])) {
$format = $config['format'];
$handler->setFormatter(new LineFormatter($format['output'], $format['date']));
}
$logger->pushHandler($handler);
$this->channels[$channel] = $logger;
} | php | {
"resource": ""
} |
q265657 | LocationController.getObjectsAction | test | public function getObjectsAction()
{
$qb = $this->getQueryBuilder();
$qb->select(\CampaignChain\CoreBundle\Controller\REST\LocationController::SELECT_STATEMENT);
$qb->from('CampaignChain\CoreBundle\Entity\Location', 'l');
$qb->where('l.channel IS NULL');
$qb->orderBy('l.name');
$qb = $this->getModuleRelation($qb, 'l.locationModule', self::MODULE_URI);
$qb = $this->getLocationChannelId($qb);
$query = $qb->getQuery();
return $this->response(
$query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)
);
} | php | {
"resource": ""
} |
q265658 | ReflectionClass.factory | test | public static function factory($class)
{
if (is_object($class))
$class = get_class($class);
$class = (string)$class;
if (!isset(self::$classes[$class]))
self::$classes[$class] = new self($class);
return self::$classes[$class];
} | php | {
"resource": ""
} |
q265659 | ReflectionClass.getInterfaces | test | public function getInterfaces()
{
$interfaceNames = $this->getInterfaceNames();
$interfaces = array();
foreach ($interfaceNames as $interface)
$interfaces[$interface] = ReflectionClass::factory($interface);
return $interfaces;
} | php | {
"resource": ""
} |
q265660 | ReflectionClass.getParentClass | test | public function getParentClass()
{
$parentClass = parent::getParentClass();
if ($parentClass) {
return ReflectionClass::factory($parentClass->getName());
}
return false;
} | php | {
"resource": ""
} |
q265661 | ReflectionClass.getMethods | test | public function getMethods($filter = null)
{
$args = func_get_args();
$methods = ReflectionMethod::factory($this->name);
if (count($args)) {
return $this->filter($methods, current($args));
}
return $methods;
} | php | {
"resource": ""
} |
q265662 | ReflectionClass.getProperties | test | public function getProperties($filter = null)
{
$args = func_get_args();
$properties = ReflectionProperty::factory($this->name);
if (count($args)) {
return $this->filter($properties, current($args));
}
return $properties;
} | php | {
"resource": ""
} |
q265663 | Request.is | test | public function is( $type ) {
switch ( $type ) {
case 'admin':
return is_admin();
case 'ajax':
return defined( 'DOING_AJAX' );
case 'cron':
return defined( 'DOING_CRON' );
case 'frontend':
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) && ! defined( 'REST_REQUEST' );
}
} | php | {
"resource": ""
} |
q265664 | StyleAggregate.addStyle | test | public function addStyle(MaterializedResource $resource, $mediaType = 'all')
{
$this->styles[$resource->getPath()] = array(
'resource' => $resource,
'content' => $resource->getContent(),
'media' => $mediaType,
);
} | php | {
"resource": ""
} |
q265665 | StyleAggregate.getAggregateStyle | test | public function getAggregateStyle()
{
$styles = $this->rewritePaths($this->styles);
$styles = $this->wrapMediaRules($styles);
$content = $this->concatenateStyles($styles);
$content = $this->moveImportsToStart($content);
return $content;
} | php | {
"resource": ""
} |
q265666 | StyleAggregate.rewritePaths | test | protected function rewritePaths(array $styles)
{
foreach ($styles as &$style) {
/** @var $resource MaterializedResource */
$resource = $style['resource'];
$replaceCallback = function ($match) use ($resource) {
return "url('".$resource->resolvePath($match[1])."')";
};
$style['content'] = preg_replace_callback(ResourceScanner::PATH_PATTERN, $replaceCallback, $style['content']);
}
return $styles;
} | php | {
"resource": ""
} |
q265667 | StyleAggregate.wrapMediaRules | test | protected function wrapMediaRules(array $styles)
{
foreach ($styles as &$style) {
// Wrap in media rule if a media rule does not already exist in a non-all media style.
if ($style['media'] != 'all' && strpos($style['content'], '@media') === false) {
$style['content'] = '@media '.$style['media'].' {'.$style['content'].'}';
}
}
return $styles;
} | php | {
"resource": ""
} |
q265668 | StyleAggregate.moveImportsToStart | test | protected function moveImportsToStart($content)
{
$imports = '';
$replaceCallback = function ($match) use (&$imports) {
$imports .= $match[0];
return '';
};
$content = preg_replace_callback('/@import[^;]+;/i', $replaceCallback, $content);
$content = $imports.$content;
return $content;
} | php | {
"resource": ""
} |
q265669 | SessionArchiveInFiles.get | test | public function get($id, $remove = false)
{
$self = $this;
/** @var File $file */
$file = null;
$getPromise = $this->getArchiveFilePath($id, true)->then(
function($filePath) use (&$file) {
$file = \Reaction::$app->fs->file($filePath);
return $file->exists()->then(
function() use (&$file) {
return $file->open('r');
}
);
}
)->then(
function($stream = null) use (&$file) {
return $file->getContents();
}
)->then(
function($dataStr) use ($self, &$file, $remove) {
try {
$data = $self->getHandler()->unserializeData($dataStr);
} catch (\InvalidArgumentException $exception) {
$data = null;
}
$data = is_array($data) ? $data : null;
if ($remove) {
$callback = function() use ($data) { return $data; };
return $file->remove()->then($callback, $callback);
}
return $data;
},
function() use ($id) {
$message = sprintf('Failed to restore session "%s"', $id);
throw new SessionException($message);
}
);
return resolve($getPromise);
} | php | {
"resource": ""
} |
q265670 | SessionArchiveInFiles.remove | test | public function remove($id)
{
return $this->getArchiveFilePath($id, true)->then(
function($filePath) {
$file = \Reaction::$app->fs->file($filePath);
return $file->remove();
}
);
} | php | {
"resource": ""
} |
q265671 | SessionArchiveInFiles.getArchivePath | test | protected function getArchivePath() {
if (!isset($this->_archivePath)) {
$this->_archivePath = \Reaction::$app->getAlias($this->archivePath);
$path = \Reaction::$app->getAlias($this->archivePath);
$self = $this;
$fs = \Reaction::$app->fs;
$dirAsFile = $fs->file($path);
$pathPromise = $dirAsFile->exists()->then(
null,
function() use ($path) {
return FileHelperAsc::createDir($path, 0777, true);
}
)->then(
function() use (&$self, $path) {
$self->_archivePath = $path;
return $path;
},
function() {
throw new SessionException("Failed to get session archive path");
}
);
return resolve($pathPromise);
}
return resolve($this->_archivePath);
} | php | {
"resource": ""
} |
q265672 | SessionArchiveInFiles.getArchiveFilePath | test | protected function getArchiveFilePath($id, $existCheck = false)
{
$fileName = $id . '.json';
return $this->getArchivePath()->then(
function($dirPath) use ($fileName) {
return rtrim($dirPath) . DIRECTORY_SEPARATOR . $fileName;
}
)->then(
function($filePath) use ($existCheck) {
if ($existCheck) {
return \Reaction::$app->fs->file($filePath)->exists()->then(
function() use ($filePath) {
return $filePath;
}
);
}
return resolve($filePath);
}
);
} | php | {
"resource": ""
} |
q265673 | ArrayHelper.cleanupMergedValues | test | public static function cleanupMergedValues($array = []) {
if (!is_array($array)) {
return $array;
}
foreach ($array as $key => $value) {
if($value instanceof IgnoreArrayValue || $value instanceof ReplaceArrayValue) {
$array[$key] = $value->value;
} elseif ($value instanceof UnsetArrayValue) {
unset($array[$key]);
} elseif (is_array($value)) {
$array[$key] = static::cleanupMergedValues($value);
}
}
return $array;
} | php | {
"resource": ""
} |
q265674 | ArrayHelper.filter | test | public static function filter($array, $filters)
{
$result = [];
$forbiddenVars = [];
foreach ($filters as $filter) {
static::applyArrayFilter($array, $filter, $result, $forbiddenVars);
}
foreach ($forbiddenVars as $var) {
list($globalKey, $localKey) = $var;
if (array_key_exists($globalKey, $result)) {
unset($result[$globalKey][$localKey]);
}
}
return $result;
} | php | {
"resource": ""
} |
q265675 | SystemSpec.it_should_return_terminal_screen_size | test | function it_should_return_terminal_screen_size()
{
self::getTerminalSizes()->shouldBeArray();
self::getTerminalSizes()->shouldHaveKey("width");
self::getTerminalSizes()->shouldHaveKey("height");
self::getTerminalSizes()->shouldHaveCount(2);
} | php | {
"resource": ""
} |
q265676 | HtmlHelper.style | test | public function style($content, $options = [], $encoding = null)
{
return $this->proxyWithCharset(__FUNCTION__, [$content, $options, $encoding]);
} | php | {
"resource": ""
} |
q265677 | HtmlHelper.script | test | public function script($content, $options = [], $encoding = null)
{
return $this->proxyWithCharset(__FUNCTION__, [$content, $options, $encoding]);
} | php | {
"resource": ""
} |
q265678 | HtmlHelper.mailto | test | public function mailto($text, $email = null, $options = [], $encoding = null)
{
$this->ensureTranslated($text);
$this->ensureTranslated($email);
return $this->proxyWithCharset(__FUNCTION__, [$text, $email, $options, $encoding]);
} | php | {
"resource": ""
} |
q265679 | HtmlHelper.staticControl | test | public function staticControl($value, $options = [])
{
$this->ensureTranslated($value);
return $this->proxy(__FUNCTION__, [$value, $options]);
} | php | {
"resource": ""
} |
q265680 | HtmlHelper.activeStaticControl | test | public function activeStaticControl($model, $attribute, $options = [])
{
if (isset($options['value'])) {
$this->ensureTranslated($options['value']);
}
return $this->proxy(__FUNCTION__, [$model, $attribute, $options]);
} | php | {
"resource": ""
} |
q265681 | HtmlHelper.addCssStyle | test | public function addCssStyle(&$options, $style, $overwrite = true)
{
$this->proxy(__FUNCTION__, [&$options, $style, $overwrite]);
} | php | {
"resource": ""
} |
q265682 | Publisher.makeDirectory | test | protected function makeDirectory()
{
$path = $this->getPath();
if( ! $this->filesystem()->isDirectory($path))
{
$this->filesystem()->makeDirectory($path, 0755, true);
}
return $this;
} | php | {
"resource": ""
} |
q265683 | Publisher.filesToPublish | test | public function filesToPublish($path)
{
$fs = $this->filesystem();
if( ! $fs->exists($path) && ! $fs->isDirectory($path))
{
throw new \InvalidArgumentException("$path set to be published in does not exist.");
}
if($fs->isDirectory($path))
{
$this->files = $fs->allFiles($path);
} else
{
$this->files = [$path];
}
return $this;
} | php | {
"resource": ""
} |
q265684 | User.init | test | public function init()
{
parent::init();
if ($this->identityClass === null) {
throw new InvalidConfigException('User::identityClass must be set.');
}
if ($this->enableAutoLogin && !isset($this->identityCookie['name'])) {
throw new InvalidConfigException('User::identityCookie must contain the "name" element.');
}
if (!empty($this->accessChecker) && is_string($this->accessChecker)) {
$this->accessChecker = Reaction::create($this->accessChecker);
}
} | php | {
"resource": ""
} |
q265685 | User.login | test | public function login(IdentityInterface $identity, $duration = 0)
{
//Using root resolve function for promise conversion
return resolve(true)
->then(function() use (&$identity, $duration) {
return $this->beforeLogin($identity, false, $duration);
})->then(function() use (&$identity, $duration) {
$this->switchIdentity($identity, $duration);
$id = $identity->getId();
$ip = $this->request->getUserIP();
if ($this->enableSession) {
$log = "User '$id' logged in from $ip with duration $duration.";
} else {
$log = "User '$id' logged in from $ip. Session not enabled.";
}
$this->regenerateCsrfToken();
if (Reaction::isDebug()) {
Reaction::info($log);
}
return $this->afterLogin($identity, false, $duration);
});
} | php | {
"resource": ""
} |
q265686 | User.regenerateCsrfToken | test | protected function regenerateCsrfToken()
{
$request = $this->request;
if ($request->enableCsrfCookie || $this->enableSession) {
$request->getCsrfToken(true);
}
} | php | {
"resource": ""
} |
q265687 | User.loginByCookie | test | protected function loginByCookie()
{
return $this->getIdentityAndDurationFromCookie()
->then(function($data) {
if (isset($data['identity'], $data['duration'])) {
/** @var IdentityInterface $identity */
$identity = $data['identity'];
$duration = $data['duration'];
return $this->beforeLogin($identity, true, $duration)
->then(function() use (&$identity, $duration) {
$this->switchIdentity($identity, $this->autoRenewCookie ? $duration : 0);
$id = $identity->getId();
$ip = $this->request->getUserIP();
Reaction::info("User '$id' logged in from $ip via cookie.");
return $this->afterLogin($identity, true, $duration);
});
} else {
return reject(new Error("Invalid cookie value or user identity"));
}
});
} | php | {
"resource": ""
} |
q265688 | User.getReturnUrl | test | public function getReturnUrl($defaultUrl = null)
{
$url = $this->app->session->get($this->returnUrlParam, $defaultUrl);
if (is_array($url)) {
if (isset($url[0])) {
return $this->app->urlManager->createUrl($url);
}
$url = null;
}
return $url === null ? $this->app->urlManager->getHomeUrl() : $url;
} | php | {
"resource": ""
} |
q265689 | User.loginRequired | test | public function loginRequired($checkAjax = true, $checkAcceptHeader = true)
{
$request = $this->request;
$canRedirect = !$checkAcceptHeader || $this->checkRedirectAcceptable();
if ($this->enableSession
&& $request->getIsGet()
&& (!$checkAjax || !$request->getIsAjax())
&& $canRedirect
) {
$this->setReturnUrl($request->getUrl());
}
if ($this->loginUrl !== null && $canRedirect) {
$loginUrl = (array)$this->loginUrl;
if ($loginUrl[0] !== $this->app->getRoute()->getRoutePath(true)) {
return $this->app->response->redirect($this->loginUrl);
}
}
throw new ForbiddenException(Reaction::t('rct', 'Login Required'));
} | php | {
"resource": ""
} |
q265690 | User.renewIdentityCookie | test | protected function renewIdentityCookie()
{
$name = $this->identityCookie['name'];
$value = $this->request->getCookies()->getValue($name);
if ($value !== null) {
$data = json_decode($value, true);
if (is_array($data) && isset($data[2])) {
$cookie = Reaction::create(array_merge($this->identityCookie, [
'class' => 'Reaction\Web\Cookie',
'value' => $value,
'expire' => time() + (int)$data[2],
]));
$this->app->response->getCookies()->add($cookie);
}
}
} | php | {
"resource": ""
} |
q265691 | User.renewAuthStatus | test | protected function renewAuthStatus()
{
$session = $this->app->session;
$id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($this->idParam) : null;
if ($id === null) {
$identityPromise = resolve(null);
} else {
/* @var $class IdentityInterface */
$class = $this->identityClass;
$identityPromise = $class::findIdentity($id);
}
return $identityPromise
->then(function($identity) use ($session) {
/** @var IdentityInterface $identity */
$this->setIdentity($identity);
$logoutPromise = resolve(true);
if ($identity !== null && ($this->authTimeout !== null || $this->absoluteAuthTimeout !== null)) {
$expire = $this->authTimeout !== null ? $session->get($this->authTimeoutParam) : null;
$expireAbsolute = $this->absoluteAuthTimeout !== null ? $session->get($this->absoluteAuthTimeoutParam) : null;
if ($expire !== null && $expire < time() || $expireAbsolute !== null && $expireAbsolute < time()) {
$logoutPromise = $this->logout(false);
} elseif ($this->authTimeout !== null) {
$session->set($this->authTimeoutParam, time() + $this->authTimeout);
}
}
return $logoutPromise->then(function() {
if ($this->enableAutoLogin) {
if ($this->getIsGuest()) {
return $this->loginByCookie();
} elseif ($this->autoRenewCookie) {
$this->renewIdentityCookie();
}
}
return true;
});
});
} | php | {
"resource": ""
} |
q265692 | User.can | test | public function can($permissionName, $params = [], $allowCaching = true)
{
//Special permissions for logged in status handling
if (in_array($permissionName, [static::PERMISSION_NOT_LOGGED_IN, static::PERMISSION_LOGGED_IN])) {
$isGuest = $this->getIsGuest();
if ($isGuest && static::PERMISSION_NOT_LOGGED_IN || !$isGuest && static::PERMISSION_LOGGED_IN) {
return resolve(true);
}
return reject(new Error("Uses::can() - denied by logged in status"));
}
if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
return $this->_access[$permissionName]
? resolve(true)
: reject(new Error("Uses::can() - denied"));
}
if (($accessChecker = $this->getAccessChecker()) === null) {
return reject(new Error("Uses::can() - denied (no access checker)"));
}
return $accessChecker->checkAccess($this->getId(), $permissionName, $params)
->otherwise(function() {
return false;
})
->then(function($access) use ($allowCaching, $permissionName) {
if ($allowCaching && empty($params)) {
$this->_access[$permissionName] = $access;
}
return $access ? resolve(true) : reject(new Error("Uses::can() - denied"));
});
} | php | {
"resource": ""
} |
q265693 | Day.getDaysOfWeek | test | public static function getDaysOfWeek(): array
{
return [
self::WEEK_DAY_MONDAY,
self::WEEK_DAY_TUESDAY,
self::WEEK_DAY_WEDNESDAY,
self::WEEK_DAY_THURSDAY,
self::WEEK_DAY_FRIDAY,
self::WEEK_DAY_SATURDAY,
self::WEEK_DAY_SUNDAY,
];
} | php | {
"resource": ""
} |
q265694 | File.save | test | public function save($dir, $filename = null)
{
// clean
$dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if(!$filename) {
$filename = $this->name;
}
return move_uploaded_file($this->tmp, $dir . $filename);
} | php | {
"resource": ""
} |
q265695 | QueryBuilder.execute | test | public function execute()
{
if ($this->type == self::SELECT) {
return $this->connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes);
} else {
return $this->connection->executeUpdate($this->getSQL(), $this->params, $this->paramTypes);
}
} | php | {
"resource": ""
} |
q265696 | QueryBuilder.delete | test | public function delete($delete = null, $alias = null)
{
$this->type = self::DELETE;
if (!$delete) {
return $this;
}
return $this->add('from', array(
'table' => $delete,
'alias' => $alias
));
} | php | {
"resource": ""
} |
q265697 | QueryBuilder.insert | test | public function insert($insert = null)
{
$this->type = self::INSERT;
if (!$insert) {
return $this;
}
return $this->add('from', array(
'table' => $insert
));
} | php | {
"resource": ""
} |
q265698 | QueryBuilder.innerJoin | test | public function innerJoin($fromAlias, $join, $alias, $condition = null)
{
return $this->add('join', array(
$fromAlias => array(
'joinType' => 'inner',
'joinTable' => $join,
'joinAlias' => $alias,
'joinCondition' => $condition
)
), true);
} | php | {
"resource": ""
} |
q265699 | QueryBuilder.where | test | public function where($predicates)
{
if (!(func_num_args() == 1 && $predicates instanceof CompositeExpression)) {
$predicates = new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
}
return $this->add('where', $predicates);
} | php | {
"resource": ""
} |
Subsets and Splits