_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q263700 | Account.numbers | test | public function numbers($index = 1, $size = 10, $pattern = null, $searchPattern = MatchingStrategy::STARTS_WITH)
{
return $this->numbers->invoke($index, $size, $pattern, $searchPattern);
} | php | {
"resource": ""
} |
q263701 | Cache.factory | test | static function factory($driver = null)
{
try {
switch ($driver) {
case APC:
return static::getDriver('APC');
case MEMCACHED:
try {
return static::getDriver('Memcached');
} catch (Exception $e) {
return static::getDriver('Memcache');
}
case MEMCACHE:
return static::getDriver('Memcache');
case MYSQL:
return static::getDriver('MySQL');
default:
throw new Exception();
}
} catch (Exception $e) {
$config = Config::getInstance();
$driver = $config->fallbackDriver ?: 'NoCache';
return static::getDriver($driver);
}
} | php | {
"resource": ""
} |
q263702 | Manialink.load | test | final public static function load($root = true, $timeout = 0, $version = 1, $background = self::DEFAULT_BACKGROUND, $navigable3d = false)
{
if (class_exists('\ManiaLib\Application\Config')) {
$config = \ManiaLib\Application\Config::getInstance();
self::$langsURL = $config->getLangsURL();
self::$imagesURL = $config->getImagesURL();
self::$mediaURL = $config->getMediaURL();
}
// Load the XML object
self::$domDocument = new \DOMDocument('1.0', 'utf-8');
self::$parentNodes = array();
self::$parentLayouts = array();
self::$parentFrames = array();
if ($root) {
$nodeManialink = self::$domDocument->createElement('manialink');
$nodeManialink->setAttribute('version', $version);
$nodeManialink->setAttribute('background', $background);
$nodeManialink->setAttribute('navigable3d', (int)$navigable3d);
self::$domDocument->appendChild($nodeManialink);
self::$parentNodes[] = $nodeManialink;
$nodeTimeout = self::$domDocument->createElement('timeout');
$nodeManialink->appendChild($nodeTimeout);
$nodeTimeout->nodeValue = $timeout;
} else {
$frame = self::$domDocument->createElement('frame');
self::$domDocument->appendChild($frame);
self::$parentNodes[] = $frame;
}
} | php | {
"resource": ""
} |
q263703 | Manialink.beginFrame | test | final public static function beginFrame($x = 0, $y = 0, $z = 0, $scale = null,
\ManiaLib\Gui\Layouts\AbstractLayout $layout = null)
{
$frame = new Elements\Frame();
$frame->setPosition($x, $y, $z);
$frame->setScale($scale);
if ($layout instanceof Layouts\AbstractLayout) {
$frame->setLayout($layout);
}
$frame->buildXML();
self::$parentFrames[] = $frame;
self::$parentNodes[] = $frame->getDOMElement();
self::$parentLayouts[] = $frame->getLayout();
} | php | {
"resource": ""
} |
q263704 | Manialink.endFrame | test | final public static function endFrame()
{
if (!end(self::$parentNodes)->hasChildNodes()) {
end(self::$parentNodes)->nodeValue = ' ';
}
array_pop(self::$parentNodes);
array_pop(self::$parentLayouts);
$frame = array_pop(self::$parentFrames);
$frame->save();
} | php | {
"resource": ""
} |
q263705 | Manialink.redirect | test | final public static function redirect($link, $render = true)
{
self::$domDocument = new \DOMDocument('1.0', 'utf-8');
self::$parentNodes = array();
self::$parentLayouts = array();
$redirect = self::$domDocument->createElement('redirect');
$redirect->appendChild(self::$domDocument->createTextNode($link));
self::$domDocument->appendChild($redirect);
self::$parentNodes[] = $redirect;
if ($render) {
if (ob_get_contents()) {
ob_clean();
}
header('Content-Type: text/xml; charset=utf-8');
echo self::$domDocument->saveXML();
} else {
return self::$domDocument->saveXML();
}
} | php | {
"resource": ""
} |
q263706 | Manialink.appendXML | test | static function appendXML($XML)
{
$doc = new \DOMDocument('1.0', 'utf-8');
$doc->loadXML($XML);
$node = self::$domDocument->importNode($doc->firstChild, true);
end(self::$parentNodes)->appendChild($node);
} | php | {
"resource": ""
} |
q263707 | RedirectorManager.buildDriver | test | private function buildDriver($driver, array $extra = [])
{
$router = $this->app->make(\Illuminate\Contracts\Routing\Registrar::class);
$class = Seo::getConfig("redirector.drivers.$driver.class");
$options = Seo::getConfig("redirector.drivers.$driver.options", []);
return new $class($router, array_merge($extra, $options));
} | php | {
"resource": ""
} |
q263708 | AbstractLayout.setBorder | test | function setBorder($borderWidth = 0, $borderHeight = 0)
{
$this->borderWidth = $borderWidth;
$this->xIndex = $borderWidth;
$this->borderHeight = $borderHeight;
$this->yIndex = -$borderHeight;
} | php | {
"resource": ""
} |
q263709 | StyleParser.declareFont | test | static function declareFont($name, $normal, $bold = null, $italic = null, $boldItalic = null)
{
self::$fonts[$name] = array(
0 => $normal,
StyleParser::BOLD => $bold ?: $normal,
StyleParser::ITALIC => $italic ?: $normal,
StyleParser::BOLD | StyleParser::ITALIC => $boldItalic ?: ($bold ?: ($italic ?: $normal))
);
} | php | {
"resource": ""
} |
q263710 | StyleParser.onImage | test | static function onImage($string, $image, $fontName, $x = 0, $y = 0, $size = 10, $defaultColor = '000')
{
if ($size <= 5)
self::onImageQuality($string, $image, $fontName, $x, $y, $size, $defaultColor, 3);
else if ($size <= 10)
self::onImageQuality($string, $image, $fontName, $x, $y, $size, $defaultColor, 2);
else if ($size <= 20)
self::onImageQuality($string, $image, $fontName, $x, $y, $size, $defaultColor, 1);
else
self::onImageFast($string, $image, $fontName, $x, $y, $size, $defaultColor);
} | php | {
"resource": ""
} |
q263711 | StyleParser.onImageFast | test | static function onImageFast($string, $image, $fontName, $x = 0, $y = 0, $size = 10, $defaultColor = '000')
{
$defaultColor = Color::StringToRgb24($defaultColor);
$xOffset = 0;
foreach (self::parseString($string) as $token)
$xOffset += $token->onImage($image, $fontName, $x + $xOffset, $y, $size, $defaultColor, 1);
} | php | {
"resource": ""
} |
q263712 | StyleParser.onImageQuality | test | static function onImageQuality($string, $image, $fontName, $x = 0, $y = 0, $size = 10, $defaultColor = '000', $precision = 2)
{
$defaultColor = Color::StringToRgb24($defaultColor);
$factor = 1 << ($precision > 31 ? 31 : $precision);
$tokens = self::parseString($string);
$rawText = '';
foreach ($tokens as $token)
$rawText .= $token->text;
$maxBBox = imagettfbbox($size, 0, self::$fonts[$fontName]->getFile(), $rawText);
$brush = imagecreatetruecolor($maxBBox[2] * 2, -$maxBBox[5] + 5);
imagefill($brush, 0, 0, 0x7fffffff);
$hugeBrush = imagecreatetruecolor(imagesx($brush) * $factor, imagesy($brush) * $factor);
imagefill($hugeBrush, 0, 0, 0x7fffffff);
$xOffset = 0;
foreach ($tokens as $token)
$xOffset += $token->onImage($hugeBrush, $fontName, $xOffset, imagesy($hugeBrush) * .75, $factor * $size, $defaultColor, $factor);
$brushX = $x + imagesx($brush) / 2;
$brushY = $y - imagesy($brush) * .25;
imagecopyresampled($brush, $hugeBrush, 0, 0, 0, 0, imagesx($brush), imagesy($brush), imagesx($hugeBrush), imagesy($hugeBrush));
imagesetbrush($image, $brush);
imageline($image, $brushX, $brushY, $brushX, $brushY, IMG_COLOR_BRUSHED);
} | php | {
"resource": ""
} |
q263713 | AbstractRedirector.getRedirectFor | test | public function getRedirectFor(Request $request)
{
$this->request = $request;
collect($this->getRedirectedUrls())->each(function ($redirects, $missingUrl) {
$this->router->get($missingUrl, function () use ($redirects) {
return redirect()->to(
$this->determineRedirectUrl($redirects),
$this->determineRedirectStatusCode($redirects)
);
});
});
try {
return $this->router->dispatch($request);
}
catch (\Exception $e) {
return null;
}
} | php | {
"resource": ""
} |
q263714 | EloquentRedirector.getRedirectedUrls | test | public function getRedirectedUrls()
{
return $this->getCachedRedirects()
->keyBy('old_url')
->transform(function (Redirect $item) {
return [$item->new_url, $item->status];
})
->toArray();
} | php | {
"resource": ""
} |
q263715 | EloquentRedirector.getCachedRedirects | test | protected function getCachedRedirects()
{
return cache()->remember($this->getOption('cache.key'), $this->getOption('cache.duration'), function () {
return $this->getRedirectModel()->get();
});
} | php | {
"resource": ""
} |
q263716 | PageNavigator.setSize | test | function setSize($iconSize = 5, $nullValue = null)
{
$this->arrowNext->setSize($iconSize, $iconSize);
$this->arrowPrev->setSize($iconSize, $iconSize);
$this->arrowFastNext->setSize($iconSize, $iconSize);
$this->arrowFastPrev->setSize($iconSize, $iconSize);
$this->arrowLast->setSize($iconSize, $iconSize);
$this->arrowFirst->setSize($iconSize, $iconSize);
} | php | {
"resource": ""
} |
q263717 | Button.setSelected | test | function setSelected()
{
$this->isSelected = true;
$this->selectedIcon = new \ManiaLib\Gui\Elements\Icons64x64_1(11);
$this->selectedIcon->setSubStyle(\ManiaLib\Gui\Elements\Icons64x64_1::ShowRight);
$this->selectedIcon->setValign('center');
$this->selectedIcon->setPosX(71);
$this->addCardElement($this->selectedIcon);
} | php | {
"resource": ""
} |
q263718 | MarketingMessage.invoke | test | public function invoke($from = null, $keyword = null, $to = null, $text = '')
{
if(!$from) {
throw new Exception("\$from parameter cannot be blank");
}
if(!$keyword) {
throw new Exception("\$keyword parameter cannot be blank");
}
if(!$to) {
throw new Exception("\$to parameter cannot be blank");
}
if(!$text) {
throw new Exception("\$text parameter cannot be blank");
}
return $this->exec([
'from' => $from,
'keyword' => $keyword,
'to' => $to,
'text' => $text
]);
} | php | {
"resource": ""
} |
q263719 | Music.setData | test | function setData($filename, $absoluteUrl = false)
{
if (!$absoluteUrl) {
$this->data = \ManiaLib\Gui\Manialink::$mediaURL . $filename;
} else {
$this->data = $filename;
}
} | php | {
"resource": ""
} |
q263720 | Tools.getLimitString | test | static function getLimitString($offset, $length)
{
$offset = (int)$offset;
$length = (int)$length;
if (!$offset && !$length) {
return '';
} elseif (!$offset && $length == 1) {
return 'LIMIT 1';
} else {
return 'LIMIT ' . $offset . ', ' . $length;
}
} | php | {
"resource": ""
} |
q263721 | Tools.getUpdateString | test | static function getUpdateString(array $values)
{
$tmp = array();
foreach ($values as $key => $value) {
$tmp[] = $key . '=' . $value;
}
return implode(', ', $tmp);
} | php | {
"resource": ""
} |
q263722 | Request.get | test | function get($name, $default = null)
{
if (array_key_exists($name, $this->params)) {
return $this->params[$name];
} else {
return $default;
}
} | php | {
"resource": ""
} |
q263723 | Request.getStrict | test | function getStrict($name, $message = null)
{
if (array_key_exists($name, $this->params) && $this->params[$name]) {
return $this->params[$name];
} elseif ($message) {
throw new UserException($message);
} else {
throw new InvalidArgumentException($name);
}
} | php | {
"resource": ""
} |
q263724 | Request.getPostStrict | test | function getPostStrict($name, $message = null)
{
if (array_key_exists($name, $_POST) && $_POST[$name]) {
return $_POST[$name];
} elseif ($message) {
throw new UserException($message);
} else {
throw new InvalidArgumentException($name);
}
} | php | {
"resource": ""
} |
q263725 | Request.restore | test | function restore($name)
{
if (array_key_exists($name, $this->requestParams)) {
$this->params[$name] = $this->requestParams[$name];
} else {
$this->delete($name);
}
} | php | {
"resource": ""
} |
q263726 | Request.redirectArgList | test | function redirectArgList($route = '')
{
$args = func_get_args();
array_shift($args);
$args = $this->filterArgs($args);
$manialink = $this->createLinkString($route, $args);
Response::getInstance()->redirect($manialink);
} | php | {
"resource": ""
} |
q263727 | Request.createLinkArgList | test | function createLinkArgList($route = '')
{
$args = func_get_args();
array_shift($args);
$args = $this->filterArgs($args);
return $this->createLinkString($route, $args);
} | php | {
"resource": ""
} |
q263728 | Request.createAbsoluteLinkArgList | test | function createAbsoluteLinkArgList($absoluteLink)
{
$args = func_get_args();
array_shift($args);
$args = $this->filterArgs($args);
return $absoluteLink . ($args ? '?' . http_build_query($args) : '');
} | php | {
"resource": ""
} |
q263729 | Component.incPosX | test | function incPosX($posX)
{
$oldX = $this->posX;
$this->posX += $posX;
$this->onMove($oldX, $this->posY, $this->posZ);
} | php | {
"resource": ""
} |
q263730 | Component.incPosY | test | function incPosY($posY)
{
$oldY = $this->posY;
$this->posY += $posY;
$this->onMove($this->posX, $oldY, $this->posZ);
} | php | {
"resource": ""
} |
q263731 | Component.incPosZ | test | function incPosZ($posZ)
{
$oldZ = $this->posZ;
$this->posZ += $posZ;
$this->onMove($this->posX, $this->posY, $oldZ);
} | php | {
"resource": ""
} |
q263732 | Component.setPosition | test | function setPosition()
{
$oldX = $this->posX;
$oldY = $this->posY;
$oldZ = $this->posZ;
$args = func_get_args();
if (!empty($args)) $this->posX = array_shift($args);
if (!empty($args)) $this->posY = array_shift($args);
if (!empty($args)) $this->posZ = array_shift($args);
$this->onMove($oldX, $oldY, $oldZ);
} | php | {
"resource": ""
} |
q263733 | Component.setScale | test | function setScale($scale)
{
$oldScale = $this->scale;
$this->scale = $scale;
$this->onScale($oldScale);
} | php | {
"resource": ""
} |
q263734 | Component.setValign | test | function setValign($valign)
{
$old = $this->valign;
$this->valign = $valign;
$this->onAlign($this->halign, $old);
} | php | {
"resource": ""
} |
q263735 | Component.setHalign | test | function setHalign($halign)
{
$old = $this->halign;
$this->halign = $halign;
$this->onAlign($old, $this->valign);
} | php | {
"resource": ""
} |
q263736 | Component.setAlign | test | function setAlign($halign = null, $valign = null)
{
$oldHalign = $this->halign;
$oldValign = $this->valign;
$this->valign = $valign;
$this->halign = $halign;
$this->onAlign($oldHalign, $oldValign);
} | php | {
"resource": ""
} |
q263737 | Component.setSizeX | test | function setSizeX($sizeX)
{
$oldX = $this->sizeX;
$this->sizeX = $sizeX;
$this->onResize($oldX, $this->sizeY);
} | php | {
"resource": ""
} |
q263738 | Component.setSizeY | test | function setSizeY($sizeY)
{
$oldY = $this->sizeY;
$this->sizeY = $sizeY;
$this->onResize($this->sizeX, $oldY);
} | php | {
"resource": ""
} |
q263739 | Component.setSize | test | function setSize()
{
$oldX = $this->sizeX;
$oldY = $this->sizeY;
$args = func_get_args();
if (!empty($args)) $this->sizeX = array_shift($args);
if (!empty($args)) $this->sizeY = array_shift($args);
$this->onResize($oldX, $oldY);
} | php | {
"resource": ""
} |
q263740 | Menu.addItem | test | function addItem($topItem = self::BUTTONS_TOP)
{
$item = new Button();
$item->setSubStyle(Bgs1::BgEmpty);
if ($topItem == self::BUTTONS_TOP) {
$this->items[] = $item;
} else {
$this->bottomItems[] = $item;
}
$this->lastItem = $item;
} | php | {
"resource": ""
} |
q263741 | Menu.addGap | test | function addGap($gap = 4)
{
$item = new \ManiaLib\Gui\Elements\Spacer(1, $gap);
$this->items[] = $item;
} | php | {
"resource": ""
} |
q263742 | RedirectStatuses.keys | test | public static function keys()
{
return collect([
Response::HTTP_MOVED_PERMANENTLY,
Response::HTTP_SEE_OTHER,
Response::HTTP_TEMPORARY_REDIRECT,
Response::HTTP_PERMANENTLY_REDIRECT,
]);
} | php | {
"resource": ""
} |
q263743 | RedirectStatuses.all | test | public static function all($locale = null)
{
return static::keys()->mapWithKeys(function ($code) use ($locale) {
return [$code => Seo::getTrans("redirections.statuses.{$code}", [], $locale)];
});
} | php | {
"resource": ""
} |
q263744 | ErrorHandling.fatalExceptionHandler | test | static function fatalExceptionHandler(\Exception $exception)
{
throw $exception;
file_put_contents(MANIALIB_APP_PATH . 'fatal-error.log', print_r($exception, true),
FILE_APPEND);
if (array_key_exists('HTTP_USER_AGENT', $_SERVER) && $_SERVER['HTTP_USER_AGENT'] == 'GameBox') {
echo '<manialink><timeout>0</timeout><label text="Fatal error." /></manialink>';
} else {
echo '<h1>Oops</h1>';
echo '<p>An error occured. Please try again later.</p>';
echo '<hr />';
if (\ManiaLib\Application\Config::getInstance()->debug) {
var_dump($exception);
}
}
} | php | {
"resource": ""
} |
q263745 | ErrorHandling.computeMessage | test | final static function computeMessage(\Exception $e, $styles = array(),
$additionalLines = array())
{
if (!$styles) {
$styles = static::$messageConfigs['default'];
}
$trace = $e->getTraceAsString();
$trace = explode("\n", $trace);
foreach ($trace as $key => $value) {
$trace[$key] = sprintf($styles['simpleLine'],
preg_replace('/#[0-9]*\s*/u', '', $value));
}
$file = sprintf($styles['simpleLine'], $e->getFile() . ' (' . $e->getLine() . ')');
$lines[] = sprintf($styles['title'], get_class($e));
$lines[] = '';
$lines[] = sprintf($styles['line'], 'Message', print_r($e->getMessage(), true));
$lines[] = sprintf($styles['line'], 'Code', $e->getCode());
$lines = array_merge($lines, $additionalLines, array($file), $trace);
$lines[] = '';
return implode("\n", $lines);
} | php | {
"resource": ""
} |
q263746 | ErrorHandling.computeShortMessage | test | final static function computeShortMessage(\Exception $e)
{
$message = get_class($e) . ' ' . $e->getMessage() . ' (' . $e->getCode() . ') in ' . $e->getFile() . ' at line ' . $e->getLine();
return $message;
} | php | {
"resource": ""
} |
q263747 | RedirectsMissingPages.handle | test | public function handle(Request $request, Closure $next)
{
$response = $next($request);
if ($response->getStatusCode() !== Response::HTTP_NOT_FOUND)
return $response;
return $this->redirector->getRedirectFor($request) ?: $response;
} | php | {
"resource": ""
} |
q263748 | Upload.uploadFile | test | static function uploadFile($path, $filename, $maxSize = 2097152)
{
$inputFile = file_get_contents('php://input', null, null, null, $maxSize);
// Else try to get GET data
if ($inputFile === false && array_key_exists('input', $_GET)) {
$inputFile = $_GET['input'];
}
// Check for error
if ($inputFile === false) {
throw new \Exception('Couldn\'t read input file');
}
if (!file_put_contents($path . $filename, $inputFile)) {
throw new \Exception('Couldn\'t save input file to ' . $path . $filename);
}
if (filesize($path . $filename) > $maxSize) {
// Not sure if usefull here
unlink($path . $filename);
throw new FileTooLargeException();
}
} | php | {
"resource": ""
} |
q263749 | URI.getCurrent | test | static function getCurrent()
{
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://'
: 'http://';
$current_uri = $protocol . $_SERVER['HTTP_HOST'] . self::getRequestURI();
$parts = parse_url($current_uri);
$query = '';
if (!empty($parts['query'])) {
$params = array();
parse_str($parts['query'], $params);
$params = array_filter($params);
if (!empty($params)) {
$query = '?' . http_build_query($params, '', '&');
}
}
// Use port if non default.
$port = isset($parts['port']) &&
(($protocol === 'http://' && $parts['port'] !== 80) || ($protocol === 'https://' && $parts['port'] !== 443))
? ':' . $parts['port'] : '';
// Rebuild.
return $protocol . $parts['host'] . $port . $parts['path'] . $query;
} | php | {
"resource": ""
} |
q263750 | Tools.getAlignedPosX | test | final public static function getAlignedPosX($posX, $sizeX, $halign, $newAlign)
{
if (!$halign) {
$halign = 'left';
}
$alignmentString = $halign . '|' . $newAlign;
switch ($alignmentString) {
case 'center|center':
case 'center|center2':
case 'left|left':
case 'right|right':
$factor = 0;
break;
case 'center|left':
case 'right|center':
case 'right|center2':
$factor = -0.5;
break;
case 'center|right':
case 'left|center':
case 'left|center2':
$factor = 0.5;
break;
case 'left|right':
$factor = 1;
break;
case 'right|left':
$factor = -1;
break;
default:
throw new \Exception('GUITools: Unsupported positions: ' . $alignmentString);
}
return $posX + $factor * $sizeX;
} | php | {
"resource": ""
} |
q263751 | Tools.getAlignedPosY | test | final public static function getAlignedPosY($posY, $sizeY, $valign, $newAlign)
{
switch ($valign) {
case 'top':
case null:
$valign = 'right';
break;
case 'bottom':
$valign = 'left';
break;
}
switch ($newAlign) {
case 'top':
$newAlign = 'right';
break;
case 'bottom':
$newAlign = 'left';
break;
}
return self::getAlignedPosX($posY, $sizeY, $valign, $newAlign);
} | php | {
"resource": ""
} |
q263752 | Tools.getAlignedPos | test | final public static function getAlignedPos(\ManiaLib\Gui\Element $object,
$newHalign, $newValign)
{
$newPosX = self::getAlignedPosX(
$object->getPosX(), $object->getRealSizeX(), $object->getHalign(),
$newHalign);
$newPosY = self::getAlignedPosY(
$object->getPosY(), $object->getRealSizeY(), $object->getValign(),
$newValign);
return array('x' => $newPosX, 'y' => $newPosY);
} | php | {
"resource": ""
} |
q263753 | GetMinDateTrans.build | test | public function build(\Magento\Framework\DB\Select $source = null)
{
/* this is root query builder (started from SELECT) */
$result = $this->conn->select();
/* define tables aliases for internal usage (in this method) */
$asAcc = self::AS_ACC;
$asTran = self::AS_TRAN;
/* FROM prxgt_acc_transaction */
$tbl = $this->resource->getTableName(self::E_TRAN); // name with prefix
$as = $asTran; // alias for 'current table' (currently processed in this block of code)
$exp = $this->expMin();
$cols = [
self::A_MIN_DATE => $exp
];
$result->from([$as => $tbl], $cols); // standard names for the variables
/* LEFT JOIN prxgt_acc_account */
$tbl = $this->resource->getTableName(self::E_ACC);
$as = $asAcc;
$cols = [];
/* bind account to transaction as debit account to bind asset type below (credit acc. has the same type) */
$cond = "$as." . EAcc::A_ID . "=$asTran." . ETran::A_DEBIT_ACC_ID;
$result->joinLeft([$as => $tbl], $cond, $cols);
return $result;
} | php | {
"resource": ""
} |
q263754 | Reset.quote | test | private function quote($data)
{
$conn = $this->resource->getConnection();
$result = $conn->quote($data);
return $result;
} | php | {
"resource": ""
} |
q263755 | Reset.resetAll | test | private function resetAll($dateFrom)
{
$quoted = $this->quote($dateFrom);
$where = EBalance::A_DATE . '>' . $quoted;
$result = (int)$this->daoBalance->delete($where);
return $result;
} | php | {
"resource": ""
} |
q263756 | Reset.queryDeleteByAssets | test | private function queryDeleteByAssets($assetTypeIds, $dateFrom)
{
$tblAcc = $this->resource->getTableName(EAccount::ENTITY_NAME);
$tblBal = $this->resource->getTableName(EBalance::ENTITY_NAME);
$conn = $this->resource->getConnection();
$quoted = $conn->quote($dateFrom);
$in = '';
foreach ($assetTypeIds as $id) {
$in .= (int)$id . ',';
}
$in = substr($in, 0, strlen($in) - 1);
$select = "SELECT " . EAccount::A_ID . " FROM $tblAcc";
$select .= " WHERE " . EAccount::A_ASSET_TYPE_ID . " IN ($in)";
$result = "DELETE FROM $tblBal WHERE " . EBalance::A_ACCOUNT_ID . " IN ($select)"
. " AND (" . EBalance::A_DATE . ">$quoted)";
return $result;
} | php | {
"resource": ""
} |
q263757 | ComposerBridge.configure | test | static function configure(ClassLoader $classLoader, string $vendorDirPath, bool $usePrefixes = true): void
{
$composerBasePath = $vendorDirPath . '/composer/';
$classLoader->addClassMap(require $composerBasePath . 'autoload_classmap.php');
$classLoader->setUsePrefixes($usePrefixes);
if ($usePrefixes) {
$classLoader->addPrefixes(require $composerBasePath . 'autoload_psr4.php');
$classLoader->addPrefixes(require $composerBasePath . 'autoload_namespaces.php', ClassLoader::PSR0);
}
$autoloadedFilesPath = $composerBasePath . 'autoload_files.php';
if (is_file($autoloadedFilesPath)) {
foreach (require $autoloadedFilesPath as $file) {
require $file;
}
}
} | php | {
"resource": ""
} |
q263758 | Container.getServiceIds | test | public function getServiceIds()
{
$services = [];
$reserved = ['get', 'getParameter', 'getServiceIds', 'getReturnType'];
$container = new \ReflectionClass($this);
foreach ($this->factories as $name => $factory) {
$services[] = self::underscore($name);
}
foreach ($container->getMethods() as $method) {
if (!in_array($method->name, $reserved) && preg_match('/^get(.+)$/', $method->name, $match)) {
$services[] = self::underscore($match[1]);
}
}
sort($services);
return $services;
} | php | {
"resource": ""
} |
q263759 | Container.getReturnType | test | public function getReturnType($name)
{
$container = new ReflectionClass($this);
try {
$method = $container->getMethod('get' . self::normalizeName($name));
$doc = $method->getDocComment();
if (!empty($doc)) {
preg_match('/@return ([a-zA-Z0-9_\x7f-\xff\x5c]+)/', $doc, $matches);
if (isset($matches[1])) {
return $matches[1];
}
}
} catch (ReflectionException $e) {
// method does not exist
}
// as fallback we get the service and return the used type
$service = $this->get($name);
if (is_object($service)) {
return get_class($service);
} else {
return gettype($service);
}
} | php | {
"resource": ""
} |
q263760 | CollectTransactions.exec | test | public function exec($balances, $trans)
{
$result = [];
foreach ($trans as $one) {
$accDebit = $one->getDebitAccId();
$accCredit = $one->getCreditAccId();
$timestamp = $one->getDateApplied();
$value = $one->getValue();
/* date_applied is in UTC format */
$date = $this->hlpPeriod->getPeriodCurrent($timestamp);
/**
* Process debit account:
*/
/** @var EBalance $entry Get balance on the transaction date (calculated or new) */
$entry = $this->getBalanceEntry($balances, $result, $accDebit, $date);
/* change total debit for the entry */
$totalDebit = $entry->getTotalDebit() + $value;
$entry->setTotalDebit($totalDebit);
/* change close balance for the entry */
$balanceClose = $entry->getBalanceClose() - $value;
$entry->setBalanceClose($balanceClose);
/* update calculated entries for result balances */
$result[$accDebit][$date] = $entry;
/* update current balances in the working var */
if (isset($balances[$accDebit])) {
$balances[$accDebit] -= $value;
} else {
$balances[$accDebit] = -$value;
}
/**
* Process credit account:
*/
/* get balance on the transaction date (calculated or new) */
$entry = $this->getBalanceEntry($balances, $result, $accCredit, $date);
/* change total credit for the entry */
$totalCredit = $entry->getTotalCredit() + $value;
$entry->setTotalCredit($totalCredit);
/* change close balance for the entry */
$balanceClose = $entry->getBalanceClose() + $value;
$entry->setBalanceClose($balanceClose);
/* update calculated entries for result balances */
$result[$accCredit][$date] = $entry;
/* update current balances in the working var */
if (isset($balances[$accCredit])) {
$balances[$accCredit] += $value;
} else {
$balances[$accCredit] = $value;
}
}
return $result;
} | php | {
"resource": ""
} |
q263761 | CollectTransactions.getBalanceEntry | test | private function getBalanceEntry($current, $balances, $accId, $datestamp)
{
if (isset($balances[$accId][$datestamp])) {
/* there is data for this account on this date */
$result = $balances[$accId][$datestamp];
} else {
/* there is NO data for this account on this date */
$result = new EBalance();
$result->setAccountId($accId);
$result->setDate($datestamp);
$result->setBalanceOpen(0);
$result->setTotalDebit(0);
$result->setTotalCredit(0);
$result->setBalanceClose(0);
if (isset($current[$accId])) {
/* we need to update entry balances for newly created entry */
$result->setBalanceOpen($current[$accId]);
$result->setBalanceClose($current[$accId]);
}
}
return $result;
} | php | {
"resource": ""
} |
q263762 | THierarchical.hierarchy | test | protected final static function hierarchy(){
$Hierarchy = [get_called_class()];
while(class_exists($class = get_parent_class($Hierarchy[count($Hierarchy) -1]))){
array_push($Hierarchy, $class);
}
return $Hierarchy;
} | php | {
"resource": ""
} |
q263763 | EasyCurl.changeContentType | test | public function changeContentType($type)
{
$mime = [
'json' => 'application/json',
'javascript' => 'application/javascript',
'js' => 'application/javascript',
'ogg' => 'audio/ogg',
'mpeg' => 'audio/mpeg',
'html' => 'text/html',
'plain' => 'text/plain',
'urlencoded' => 'application/x-www-form-urlencoded'
];
if (array_key_exists($type, $mime)) {
$this->unsetHeader('Content-Type');
$this->setHeader('Content-Type', $mime[$type]);
}
return $this;
} | php | {
"resource": ""
} |
q263764 | EasyCurl.headerParse | test | private function headerParse($rawHeader)
{
$headers = array();
$headerLine = substr($rawHeader, 0, strpos($rawHeader, "\r\n\r\n"));
foreach (explode("\r\n", $headerLine) as $i => $line) {
if ($i === 0) {
$headers['Status-Line'] = $line;
continue;
}
list ($key, $value) = explode(': ', $line);
$headers[$key] = $value;
}
return $headers;
} | php | {
"resource": ""
} |
q263765 | Str.convertToArray | test | public function convertToArray($string, $value)
{
$keys = explode('.', $string);
return $this->buildDimensionalArray($keys, count($keys), $value);
} | php | {
"resource": ""
} |
q263766 | Str.buildDimensionalArray | test | private function buildDimensionalArray(array $keys, $dimensions, $value)
{
$result = [];
// add first dimension
$result[$keys[0]] = [];
$pointer = &$result[$keys[0]];
for ($i = 1; $i < $dimensions; $i++) {
if ($i === ($dimensions - 1)) {
$pointer[$keys[$i]] = $value;
} else {
$pointer[$keys[$i]] = [];
$pointer = &$pointer[$keys[$i]];
}
}
return $result;
} | php | {
"resource": ""
} |
q263767 | Calc.getAssetTypes | test | private function getAssetTypes($typeIds, $typeCodes)
{
$result = [];
$types = $this->daoTypeAsset->get();
if (
empty($typeIds) &&
empty($typeCodes)
) {
/* return all asset types */
/** @var ETypeAsset $type */
foreach ($types as $type) {
$typeId = $type->getId();
$typeCode = $type->getCode();
$result[$typeId] = $typeCode;
}
} else {
/* validate ID for given type ID or convert type code to type ID */
/** @var ETypeAsset $type */
foreach ($types as $type) {
$typeId = $type->getId();
$typeCode = $type->getCode();
if (
(is_array($typeIds) && in_array($typeId, $typeIds)) ||
(is_array($typeCodes) && in_array($typeCode, $typeCodes))
) {
$result[$typeId] = $typeCode;
}
}
}
return $result;
} | php | {
"resource": ""
} |
q263768 | ProcessOneAsset.exec | test | public function exec($assetTypeId)
{
/* get the last date with balances for given asset then take previous date */
$dsLast = $this->getDateBalanceClose($assetTypeId);
$dsPrev = $this->hlpPeriod->getPeriodPrev($dsLast);
/* get all closing balances for previous date */
$balances = $this->getBalances($assetTypeId, $dsPrev);
/* get all accounts with given asset type */
$accounts = $this->getAccounts($assetTypeId);
/* get all transactions starting from "balance close -1 day" for given asset */
$trans = $this->getTransactions($assetTypeId, $dsPrev);
/* then validate current balances */
$this->validate($accounts, $balances, $trans);
} | php | {
"resource": ""
} |
q263769 | ProcessOneAsset.getDateBalanceClose | test | private function getDateBalanceClose($typeId)
{
$req = new ARequestLastDate();
$req->setAssetTypeId($typeId);
/** @var AResponseLastDate $resp */
$resp = $this->servLastDate->exec($req);
$result = $resp->getLastDate();
return $result;
} | php | {
"resource": ""
} |
q263770 | ResponseController.checkAction | test | public function checkAction($strategy)
{
$config = $this->get('dcs_opauth.strategy_parser')->get($strategy);
$opauth = new \Opauth($config, false);
$this->dispatchEvent(DCSOpauthEvents::BEFORE_PARSE_RESPONSE, new OpauthEvent($opauth));
$responseData = $this->get('dcs_opauth.response_parser')->parse($opauth);
// Check if there are errors from the provider
$isValid = !isset($responseData['error']);
$event = new OpauthResponseEvent($opauth, $responseData, $isValid);
$this->dispatchEvent(DCSOpauthEvents::AFTER_PARSE_RESPONSE, $event);
// If there are no errors, and authentication is enabled, create the token with the data provider
if ($isValid && $event->getAuthenticate()) {
$this->get('dcs_opauth.authenticator')->authenticate($responseData);
}
// Verify if the response is set
if (null === $response = $event->getResponse()) {
if ($isValid) {
if (null === $routeRedirect = $this->container->getParameter('dcs_opauth.redirect_after_response')) {
$url = '/'.ltrim($this->get('request')->getBaseUrl(), '/');
} else {
// Check if route exists
try {
$url = $this->generateUrl($routeRedirect);
} catch (RouteNotFoundException $e) {
$url = $routeRedirect;
}
}
// Create default response
$response = new RedirectResponse($url);
} else {
$response = $this->render($this->container->getParameter('dcs_opauth.error_view'), $responseData['error']);
}
}
return $response;
} | php | {
"resource": ""
} |
q263771 | TMutatable.mutate | test | protected final function mutate(string $prefix, string $name, $value = null) {
return method_exists($this, $method = Src::tcm(strtolower(Str::join('_', $prefix, $name , 'property'))))
? call_user_func([$this, $method], $value) : $value;
} | php | {
"resource": ""
} |
q263772 | Client.fetch | test | public function fetch($url)
{
$this->builder = new Builder(urlencode($url));
foreach ($this->defaults as $key => $value) {
if (method_exists($this->builder, $key)) {
call_user_func([$this->builder, $key], $value);
}
}
return $this;
} | php | {
"resource": ""
} |
q263773 | Client.url | test | public function url()
{
if (!isset($this->config['url'])) {
throw InvalidConfigurationException::urlNotDefined();
}
if (!isset($this->config['client'])) {
throw InvalidConfigurationException::clientNotDefined();
}
return implode('/', array_filter([
$this->config['url'],
$this->config['client'],
$this->getResourceKey(),
$this->getTypeKey(),
$this->builder->getManipulations(),
$this->builder->getKey(),
]));
} | php | {
"resource": ""
} |
q263774 | LazyStrings.generate | test | public function generate()
{
// validate doc url and sheets
if (!$this->validator->validateDocUrl($this->csvUrl)) {
throw new Exception('Provided doc url is not valid.');
}
$this->validator->validateSheets($this->sheets);
$strings = [];
foreach ($this->sheets as $locale => $csvId) {
// create locale directories
$this->createDirectory($this->target . '/' . $locale);
$localized = $this->localize($csvId);
$strings[$locale] = $localized;
// create strings in language file
$stringsFile = $this->target . '/' . $locale . '/' . $this->languageFilename . '.php';
$phpFormatted = '<?php return ' . var_export($localized, true) . ';';
file_put_contents($stringsFile, $phpFormatted);
// save strings in json format
$this->backup($localized, $this->backup, $locale . '.json');
}
return $strings;
} | php | {
"resource": ""
} |
q263775 | LazyStrings.parse | test | private function parse($csvUrl)
{
$csvFile = fopen($csvUrl, 'r');
$strings = [];
if ($csvFile !== false) {
while (($row = fgetcsv($csvFile, 1000, ',')) !== false) {
if ($row[0] !== '' && $row[0] !== 'id') {
$id = $this->str->strip($row[0]);
$value = $row[1];
if ($this->nested) {
if ($this->str->hasDots($id)) {
$strings = array_replace_recursive($strings, $this->str->convertToArray($id, $value));
} else {
$strings[$id] = $value;
}
} else {
$strings[$id] = $value;
}
}
}
fclose($csvFile);
}
return $strings;
} | php | {
"resource": ""
} |
q263776 | LazyStrings.localize | test | private function localize($csvId)
{
$strings = [];
$urlPart = '&single=true&gid=';
if (is_array($csvId)) {
foreach ($csvId as $id) {
$parsed = $this->parse($this->csvUrl . $urlPart . $id);
$strings = array_merge($strings, $parsed);
}
} else {
$strings = $this->parse($this->csvUrl . $urlPart . $csvId);
}
return $strings;
} | php | {
"resource": ""
} |
q263777 | LazyStrings.backup | test | private function backup(array $strings, $path, $filename)
{
$stringsFile = $path . '/' . $filename;
$jsonStrings = json_encode($strings, JSON_PRETTY_PRINT);
$this->createDirectory($path);
file_put_contents($stringsFile, $jsonStrings);
} | php | {
"resource": ""
} |
q263778 | Account.getAllByAssetTypeCode | test | public function getAllByAssetTypeCode($assetTypeCode)
{
/* aliases and tables */
$asType = 'at';
$asAcc = 'acc';
/* SELECT FROM prxgt_acc_type_asset */
$query = $this->conn->select();
$tbl = $this->resource->getTableName(TypeAsset::ENTITY_NAME);
$cols = [];
$query->from([$asType => $tbl], $cols);
/* LEFT JOIN prxgt_acc_account */
$tbl = $this->resource->getTableName(Entity::ENTITY_NAME);
$on = $asAcc . '.' . Entity::A_ASSET_TYPE_ID . '=' . $asType . '.' . TypeAsset::A_ID;
$cols = [
Entity::A_ID,
Entity::A_ASSET_TYPE_ID,
Entity::A_BALANCE,
Entity::A_CUST_ID
];
$query->joinLeft([$asAcc => $tbl], $on, $cols);
/* WHERE */
$where = $asType . '.' . TypeAsset::A_CODE . '=:' . self::BIND_CODE;
$query->where($where);
/* bind vars and fetch results */
$bind = [self::BIND_CODE => $assetTypeCode];
$rs = $this->conn->fetchAll($query, $bind);
$result = [];
foreach ($rs as $one) {
$item = new Entity($one);
$result[$item->getId()] = $item;
}
return $result;
} | php | {
"resource": ""
} |
q263779 | Account.getAssetTypeId | test | public function getAssetTypeId($accountId)
{
$result = null;
/** @var Entity $entity */
$entity = $this->getById($accountId);
if ($entity) {
$result = $entity->getAssetTypeId();
}
return $result;
} | php | {
"resource": ""
} |
q263780 | Account.getCustomerAccByAssetCode | test | public function getCustomerAccByAssetCode($customerId, $assetTypeCode)
{
$assetTypeId = $this->daoTypeAsset->getIdByCode($assetTypeCode);
$result = $this->getByCustomerId($customerId, $assetTypeId);
return $result;
} | php | {
"resource": ""
} |
q263781 | Account.getSystemCustomerId | test | public function getSystemCustomerId()
{
if (is_null($this->cachedSysCustId)) {
$conn = $this->conn;
/* there is no cached value for the customer ID, select data from DB */
$where = Cfg::E_CUSTOMER_A_EMAIL . '=' . $conn->quote(Cfg::SYS_CUSTOMER_EMAIL);
$data = $this->daoGeneric->getEntities(Cfg::ENTITY_MAGE_CUSTOMER, Cfg::E_CUSTOMER_A_ENTITY_ID,
$where);
if (count($data) == 0) {
$bind = [
Cfg::E_CUSTOMER_A_WEBSITE_ID => Cfg::DEF_WEBSITE_ID_ADMIN,
Cfg::E_CUSTOMER_A_EMAIL => Cfg::SYS_CUSTOMER_EMAIL
];
$id = $this->daoGeneric->addEntity(Cfg::ENTITY_MAGE_CUSTOMER, $bind);
if ($id > 0) {
$this->cachedSysCustId = $id;
}
} else {
$first = reset($data);
$this->cachedSysCustId = $first[Cfg::E_CUSTOMER_A_ENTITY_ID];
}
}
return $this->cachedSysCustId;
} | php | {
"resource": ""
} |
q263782 | Create.exec | test | public function exec($request)
{
assert($request instanceof ARequest);
$result = new AResponse();
$debitAccId = $request->getDebitAccId();
$creditAccId = $request->getCreditAccId();
$operationId = $request->getOperationId();
$dateApplied = $request->getDateApplied();
$value = $request->getValue();
$note = $request->getNote();
/* limit amount by MIN & MAX */
if (
($value > Cfg::LIMIT_AMOUNT_MAX) ||
($value < Cfg::LIMIT_AMOUNT_MIN)
) {
throw new \Exception("Illegal value for amount transaction: $value.");
}
/* get account type for debit account */
$debitAcc = $this->daoAcc->getById($debitAccId);
$debitAssetTypeId = $debitAcc->getAssetTypeId();
/* get account type for credit account */
$creditAcc = $this->daoAcc->getById($creditAccId);
$creditAssetTypeId = $creditAcc->getAssetTypeId();
/* asset types should be equals */
if (
!is_null($debitAssetTypeId) &&
($debitAssetTypeId == $creditAssetTypeId)
) {
/* add transaction */
$toAdd = [
ETransaction::A_OPERATION_ID => $operationId,
ETransaction::A_DEBIT_ACC_ID => $debitAccId,
ETransaction::A_CREDIT_ACC_ID => $creditAccId,
ETransaction::A_VALUE => $value,
ETransaction::A_DATE_APPLIED => $dateApplied
];
if (!is_null($note)) {
$toAdd[ETransaction::A_NOTE] = $note;
}
$idCreated = $this->daoTrans->create($toAdd);
$result->setTransactionId($idCreated);
} else {
throw new \Exception("Asset type (#$debitAssetTypeId) for debit account #$debitAccId is not equal to "
. "asset type (#$creditAssetTypeId) for credit account $creditAccId.");
}
$result->markSucceed();
return $result;
} | php | {
"resource": ""
} |
q263783 | DCSOpauthExtension.buildStrategiesKey | test | private function buildStrategiesKey($strategies)
{
foreach ($strategies as $name => $config) {
switch ($config['strategy_class']) {
case 'Basecamp':
case 'Behance':
case 'Bitly':
case 'Do':
case 'Dropbox':
case 'Evernote':
case 'Foursquare':
case 'GitHub':
case 'Google':
case 'Harvest':
case 'Instagram':
case 'Live':
case 'Mixi':
case 'Strava':
case 'Yahoojp':
case 'Yammer':
case 'ResourceGuru':
$config['client_id'] = $config['id'];
$config['client_secret'] = $config['secret'];
unset($config['id']);
unset($config['secret']);
break;
case 'Bitbucket':
case 'Flickr':
case 'SinaWeibo':
case 'Twitter':
case 'Vimeo':
$config['key'] = $config['id'];
unset($config['id']);
break;
case 'Disqus':
$config['api_key'] = $config['id'];
$config['api_secret'] = $config['secret'];
unset($config['id']);
unset($config['secret']);
break;
case 'LinkedIn':
$config['api_key'] = $config['id'];
$config['secret_key'] = $config['secret'];
unset($config['id']);
unset($config['secret']);
break;
case 'Facebook':
case 'PayPal':
case 'VKontakte':
$config['app_id'] = $config['id'];
$config['app_secret'] = $config['secret'];
unset($config['id']);
unset($config['secret']);
break;
case 'Tumblr':
$config['consumer_key'] = $config['id'];
$config['consumer_secret'] = $config['secret'];
unset($config['id']);
unset($config['secret']);
break;
}
// Set new configuration
$strategies[$name] = $config;
}
return $strategies;
} | php | {
"resource": ""
} |
q263784 | ResponseParser.parse | test | public function parse(\Opauth $opauth)
{
$callbackTransport = $opauth->env['callback_transport'];
switch($callbackTransport) {
case 'session':
$response = $_SESSION['opauth'];
unset($_SESSION['opauth']);
break;
case 'post':
$response = unserialize(base64_decode($_POST['opauth']));
break;
case 'get':
$response = unserialize(base64_decode($_GET['opauth']));
break;
default:
throw new UnsupportedCallbackException(sprintf('Callback transport "%s" is not supported. Are only supported: session, post, get', $callbackTransport));
break;
}
return $response;
} | php | {
"resource": ""
} |
q263785 | ConnectController.loginAction | test | public function loginAction($strategy)
{
$config = $this->get('dcs_opauth.strategy_parser')->get($strategy);
$opauth = new \Opauth($config);
} | php | {
"resource": ""
} |
q263786 | View.render | test | public function render($path, $data = [])
{
$this->data = array_merge($this->data, $data);
$this->setPath($path);
$contents = $this->renderContents();
return $contents;
} | php | {
"resource": ""
} |
q263787 | Validate.getAssetTypes | test | private function getAssetTypes()
{
$result = [];
$types = $this->daoTypeAsset->get();
/** @var ETypeAsset $type */
foreach ($types as $type) {
$typeId = $type->getId();
$typeCode = $type->getCode();
$result[$typeId] = $typeCode;
}
return $result;
} | php | {
"resource": ""
} |
q263788 | ServerResponse.send | test | public function send()
{
if ($this->getProtocolVersion() && $this->getStatusCode()) {
header(static::VERSION_DELIMITER . $this->getProtocolVersion() . ' ' . $this->getStatusCode() . ' ' . $this->getReasonPhrase());
}
foreach ($this->getHeaders() as $key => $value) {
header($key . static::HEADER_DELIMITER . implode(static::HEADER_VALUE_DELIMITER, $value));
}
echo $this->getBody();
} | php | {
"resource": ""
} |
q263789 | Authenticator.authenticate | test | public function authenticate($responseData)
{
$token = new OpauthToken($responseData, $this->roles);
$this->securityContext->setToken($token);
} | php | {
"resource": ""
} |
q263790 | VerifyApiToken.verifyToken | test | protected function verifyToken(Request $request)
{
$time = (int) ($request->input('_time') ?: $request->header('X-API-TIME'));
$token = $request->input('_token') ?: $request->header('X-API-TOKEN');
return abs(time() - $time) < (int) config('api.token_duration') &&
$this->token->verify($token, $this->getKeyFromRequest($request), $time);
} | php | {
"resource": ""
} |
q263791 | Validator.validateDocUrl | test | public function validateDocUrl($url)
{
$pattern = '/http:\/\/docs\.google\.com\/spreadsheets\/d\/.*\/export\?format=csv/';
if (is_null($url) || $url === '' || preg_match($pattern, $url) !== 1) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q263792 | ApiServiceProvider.registerClient | test | protected function registerClient()
{
$this->app->singleton('api.client', function ($app) {
$client = new Client(
$app['encrypter'],
$app['config']->get('api.clients', [])
);
$client->setDefaultAppKey($app['config']->get('api.default_client'));
return $client;
});
$this->app->alias('api.client', Client::class);
} | php | {
"resource": ""
} |
q263793 | ApiServiceProvider.registerToken | test | protected function registerToken()
{
$this->app->singleton('api.token', function ($app) {
return new Token($app['api.client']);
});
$this->app->alias('api.token', Token::class);
} | php | {
"resource": ""
} |
q263794 | ApiServiceProvider.registerForConsole | test | protected function registerForConsole()
{
$this->publishes([
__DIR__.'/../config/api.php' => base_path('config/api.php'),
], 'laravel-api');
$this->commands([
Console\GenerateClientCommand::class,
Console\GenerateTokenCommand::class,
]);
} | php | {
"resource": ""
} |
q263795 | Session.start | test | public static function start($name = null)
{
if (session_status() !== PHP_SESSION_NONE) {
throw new \RuntimeException('Can\'t start a new session.');
}
if ($name !== null) {
session_name($name);
}
session_start();
} | php | {
"resource": ""
} |
q263796 | TRetrospective.retrospect | test | protected final static function retrospect(string $name){
return call_user_func_array('array_merge', array_map(function($class) use ($name){
return property_exists($class, $name) ? $class::${$name} : [];
}, array_reverse(static::hierarchy())));
} | php | {
"resource": ""
} |
q263797 | Response.setStatus | test | private function setStatus($statusCode, $reasonPhrase = '')
{
if ($reasonPhrase === '' && isset(self::$reasonPhrases[$statusCode])) {
$reasonPhrase = self::$reasonPhrases[$statusCode];
}
$this->statusCode = $statusCode;
$this->reasonPhrase = $reasonPhrase;
return $this;
} | php | {
"resource": ""
} |
q263798 | Tokenizer.tree | test | public function tree($css) {
// Do stuff
$this->_tokens = $this->tokenize($css);
$results = $this->_parseTokens(array_shift($this->_tokens));
// Add remaining items to root element
while (count($this->_tokens)) {
if (!$this->ignoreErrors) {
$this->errors[] = new ParseError('Unmatched }', $this->_css, $this->_tokens[0]['index']);
}
$results = array_merge($results, $this->_parseTokens(array_shift($this->_tokens)));
}
return $results;
} | php | {
"resource": ""
} |
q263799 | Tokenizer._findTokens | test | protected function _findTokens($tokens) {
$list = [];
foreach ($tokens as $token) {
$index = 0;
while (true) {
$index = strpos($this->_cssLC, $token, $index);
if ($index === false) {
break;
}
$list[] = [
'token' => $token,
'index' => $index
];
$index ++;
}
}
usort($list, function($a, $b) {
return $a['index'] - $b['index'];
});
return $list;
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.