_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q256500 | Export.setTemplate | test | public function setTemplate($template)
{
if (is_string($template)) {
if (substr($template, 0, 8) === '__SELF__') {
$this->templates = $this->getTemplatesFromString(substr($template, 8));
$this->templates[] = $this->twig->loadTemplate(static::DEFAULT_TEMPLATE);
... | php | {
"resource": ""
} |
q256501 | Export.getParameter | test | public function getParameter($name)
{
if (!$this->hasParameter($name)) {
throw new \InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
}
return $this->parameters[$name];
} | php | {
"resource": ""
} |
q256502 | ActionsColumn.getActionsToRender | test | public function getActionsToRender($row)
{
$list = $this->rowActions;
foreach ($list as $i => $a) {
$action = clone $a;
$list[$i] = $action->render($row);
if (null === $list[$i]) {
unset($list[$i]);
}
}
return $list;
... | php | {
"resource": ""
} |
q256503 | Cart.clear | test | public function clear($save = true): self
{
$this->items = [];
$save && $this->storage->save($this);
return $this;
} | php | {
"resource": ""
} |
q256504 | Cart.add | test | public function add(CartItemInterface $element, $save = true): self
{
$this->addItem($element);
$save && $this->storage->save($this);
return $this;
} | php | {
"resource": ""
} |
q256505 | Cart.remove | test | public function remove($uniqueId, $save = true): self
{
if (!isset($this->items[$uniqueId])) {
throw new InvalidParamException('Item not found');
}
unset($this->items[$uniqueId]);
$save && $this->storage->save($this);
return $this;
} | php | {
"resource": ""
} |
q256506 | Cart.getItems | test | public function getItems($itemType = null): array
{
$items = $this->items;
if (!is_null($itemType)) {
$items = array_filter(
$items,
function ($item) use ($itemType) {
/* @var $item CartItemInterface */
return is_a(... | php | {
"resource": ""
} |
q256507 | Auth0Service.login | test | public function login($connection = null, $state = null, $additional_params = ['scope' => 'openid profile email'], $response_type = 'code')
{
$additional_params['response_type'] = $response_type;
$this->auth0->login($state, $connection, $additional_params);
} | php | {
"resource": ""
} |
q256508 | Auth0Service.getUser | test | public function getUser()
{
// Get the user info from auth0
$auth0 = $this->getSDK();
$user = $auth0->getUser();
if ($user === null) {
return;
}
return [
'profile' => $user,
'accessToken' => $auth0->getAccessToken(),
];
... | php | {
"resource": ""
} |
q256509 | Auth0Service.rememberUser | test | public function rememberUser($value = null)
{
if ($value !== null) {
$this->rememberUser = $value;
}
return $this->rememberUser;
} | php | {
"resource": ""
} |
q256510 | Auth0Controller.callback | test | public function callback()
{
// Get a handle of the Auth0 service (we don't know if it has an alias)
$service = \App::make('auth0');
// Try to get the user information
$profile = $service->getUser();
// Get the user related to the profile
$auth0User = $this->userRep... | php | {
"resource": ""
} |
q256511 | S.length | test | public static function length($string)
{
if (function_exists('mb_strlen')) {
return mb_strlen($string, static::getEncoding());
}
if (function_exists('iconv_strlen')) {
return iconv_strlen($string, static::getEncoding());
}
return false;
} | php | {
"resource": ""
} |
q256512 | S.slice | test | public static function slice($string, $start, $end = null)
{
if ($end !== null) {
$end -= $start;
}
if (function_exists('mb_substr')) {
return mb_substr($string, $start, $end, static::getEncoding());
}
if (function_exists('iconv_substr')) {
... | php | {
"resource": ""
} |
q256513 | S.lower | test | public static function lower($string)
{
if (function_exists('mb_strtolower')) {
return mb_strtolower($string, static::getEncoding());
}
return static::replaceByMap($string, static::$cyrillicAlphabet[0], static::$cyrillicAlphabet[1]);
} | php | {
"resource": ""
} |
q256514 | S.upper | test | public static function upper($string)
{
if (function_exists('mb_strtoupper')) {
return mb_strtoupper($string, static::getEncoding());
}
return static::replaceByMap($string, static::$cyrillicAlphabet[1], static::$cyrillicAlphabet[0]);
} | php | {
"resource": ""
} |
q256515 | PHPMock.getFunctionMock | test | public function getFunctionMock($namespace, $name)
{
$delegateBuilder = new MockDelegateFunctionBuilder();
$delegateBuilder->build($name);
$mock = $this->getMockBuilder($delegateBuilder->getFullyQualifiedClassName())->getMockForAbstractClass();
$mock->__phpunit_getI... | php | {
"resource": ""
} |
q256516 | PHPMock.registerForTearDown | test | public function registerForTearDown(Deactivatable $deactivatable)
{
$result = $this->getTestResultObject();
$result->addListener(new MockDisabler($deactivatable));
} | php | {
"resource": ""
} |
q256517 | PHPMock.defineFunctionMock | test | public static function defineFunctionMock($namespace, $name)
{
$functionMockBuilder = new MockBuilder();
$functionMockBuilder->setNamespace($namespace)
->setName($name)
->setFunction(function () {
})
... | php | {
"resource": ""
} |
q256518 | Language.flag | test | public static function flag($code = 'default')
{
if ($code == 'default') {
$code = app()->getLocale();
}
$name = self::getName($code);
$code = self::country($code);
return view('vendor.language.flag', compact('code', 'name'));
} | php | {
"resource": ""
} |
q256519 | Language.country | test | public static function country($locale = 'default')
{
if ($locale == 'default') {
$locale = app()->getLocale();
}
if (config('language.mode.code', 'short') == 'short') {
$code = strtolower(substr(self::getLongCode($locale), 3));
} else {
$code = s... | php | {
"resource": ""
} |
q256520 | Language.getCode | test | public static function getCode($name = 'default')
{
if ($name == 'default') {
$name = self::getName();
}
return self::codes([$name])[$name];
} | php | {
"resource": ""
} |
q256521 | Language.getLongCode | test | public static function getLongCode($short = 'default')
{
if ($short == 'default') {
$short = app()->getLocale();
}
$long = 'en-GB';
// Get languages from config
$languages = config('language.all');
foreach ($languages as $language) {
if ($la... | php | {
"resource": ""
} |
q256522 | Language.getName | test | public static function getName($code = 'default')
{
if ($code == 'default') {
$code = app()->getLocale();
}
return self::names([$code])[$code];
} | php | {
"resource": ""
} |
q256523 | Language.setLocale | test | private function setLocale($locale, $request)
{
// Check if is allowed and set default locale if not
if (!language()->allowed($locale)) {
$locale = config('app.locale');
}
if (Auth::check()) {
Auth::user()->setAttribute('locale', $locale)->save();
} e... | php | {
"resource": ""
} |
q256524 | Language.home | test | public function home($locale, Request $request)
{
$this->setLocale($locale, $request);
$url = config('language.url') ? url('/' . $locale) : url('/');
return redirect($url);
} | php | {
"resource": ""
} |
q256525 | Language.back | test | public function back($locale, Request $request)
{
$this->setLocale($locale, $request);
$session = $request->session();
if (config('language.url')) {
$previous_url = substr(str_replace(env('APP_URL'), '', $session->previousUrl()), 7);
if (strlen($previous_url) == 3)... | php | {
"resource": ""
} |
q256526 | SetLocale.setLocale | test | private function setLocale($locale)
{
// Check if is allowed and set default locale if not
if (!language()->allowed($locale)) {
$locale = config('app.locale');
}
// Set app language
\App::setLocale($locale);
// Set carbon language
if (config('lan... | php | {
"resource": ""
} |
q256527 | AbstractSequence.indexWhere | test | public function indexWhere($callable)
{
foreach ($this->elements as $i => $element) {
if (call_user_func($callable, $element) === true) {
return $i;
}
}
return -1;
} | php | {
"resource": ""
} |
q256528 | AbstractSequence.remove | test | public function remove($index)
{
if ( ! isset($this->elements[$index])) {
throw new OutOfBoundsException(sprintf('The index "%d" is not in the interval [0, %d).', $index, count($this->elements)));
}
$element = $this->elements[$index];
unset($this->elements[$index]);
... | php | {
"resource": ""
} |
q256529 | AbstractSequence.takeWhile | test | public function takeWhile($callable)
{
$newElements = array();
for ($i=0,$c=count($this->elements); $i<$c; $i++) {
if (call_user_func($callable, $this->elements[$i]) !== true) {
break;
}
$newElements[] = $this->elements[$i];
}
re... | php | {
"resource": ""
} |
q256530 | SMTP.setAuth | test | public function setAuth($username, $password)
{
$this->username = $username;
$this->password = $password;
$this->logger && $this->logger->debug("Set: the auth login");
return $this;
} | php | {
"resource": ""
} |
q256531 | SMTP.setOAuth | test | public function setOAuth($accessToken)
{
$this->oauthToken = $accessToken;
$this->logger && $this->logger->debug("Set: the auth oauthbearer");
return $this;
} | php | {
"resource": ""
} |
q256532 | SMTP.send | test | public function send(Message $message)
{
$this->logger && $this->logger->debug('Set: a message will be sent');
$this->message = $message;
$this->connect()
->ehlo();
if ($this->secure === 'tls' || $this->secure === 'tlsv1.0' || $this->secure === 'tlsv1.1' | $this->secure ... | php | {
"resource": ""
} |
q256533 | SMTP.connect | test | protected function connect()
{
$this->logger && $this->logger->debug("Connecting to {$this->host} at {$this->port}");
$host = ($this->secure == 'ssl') ? 'ssl://' . $this->host : $this->host;
$this->smtp = @fsockopen($host, $this->port);
//set block mode
// stream_set_block... | php | {
"resource": ""
} |
q256534 | SMTP.starttls | test | protected function starttls()
{
$in = "STARTTLS" . $this->CRLF;
$code = $this->pushStack($in);
if ($code !== '220'){
throw new CodeException('220', $code, array_pop($this->resultStack));
}
if ($this->secure !== 'tls' && version_compare(phpversion(), '5.6.0', '<')... | php | {
"resource": ""
} |
q256535 | SMTP.authLogin | test | protected function authLogin()
{
$in = "AUTH LOGIN" . $this->CRLF;
$code = $this->pushStack($in);
if ($code !== '334'){
throw new CodeException('334', $code, array_pop($this->resultStack));
}
$in = base64_encode($this->username) . $this->CRLF;
$code = $thi... | php | {
"resource": ""
} |
q256536 | SMTP.authOAuthBearer | test | protected function authOAuthBearer()
{
$authStr = sprintf("n,a=%s,%shost=%s%sport=%s%sauth=Bearer %s%s%s",
$this->message->getFromEmail(),
chr(1),
$this->host,
chr(1),
$this->port,
chr(1),
$this->oauthToken,
chr(... | php | {
"resource": ""
} |
q256537 | SMTP.authXOAuth2 | test | protected function authXOAuth2()
{
$authStr = sprintf("user=%s%sauth=Bearer %s%s%s",
$this->message->getFromEmail(),
chr(1),
$this->oauthToken,
chr(1),
chr(1)
);
$authStr = base64_encode($authStr);
$in = "AUTH XOAUTH2 $authS... | php | {
"resource": ""
} |
q256538 | SMTP.rcptTo | test | protected function rcptTo()
{
$to = array_merge(
$this->message->getTo(),
$this->message->getCc(),
$this->message->getBcc()
);
foreach ($to as $toEmail=>$_) {
$in = "RCPT TO:<" . $toEmail . ">" . $this->CRLF;
$code = $this->pushStac... | php | {
"resource": ""
} |
q256539 | SMTP.data | test | protected function data()
{
$in = "DATA" . $this->CRLF;
$code = $this->pushStack($in);
if ($code !== '354') {
throw new CodeException('354', $code, array_pop($this->resultStack));
}
$in = $this->message->toString();
$code = $this->pushStack($in);
i... | php | {
"resource": ""
} |
q256540 | SMTP.quit | test | protected function quit()
{
$in = "QUIT" . $this->CRLF;
$code = $this->pushStack($in);
if ($code !== '221'){
throw new CodeException('221', $code, array_pop($this->resultStack));
}
return $this;
} | php | {
"resource": ""
} |
q256541 | SMTP.getCode | test | protected function getCode()
{
while ($str = fgets($this->smtp, 515)) {
$this->logger && $this->logger->debug("Got: ". $str);
$this->resultStack[] = $str;
if(substr($str,3,1) == " ") {
$code = substr($str,0,3);
return $code;
}
... | php | {
"resource": ""
} |
q256542 | Message.setFrom | test | public function setFrom($name, $email)
{
$this->fromName = $name;
$this->fromEmail = $email;
return $this;
} | php | {
"resource": ""
} |
q256543 | Message.setFakeFrom | test | public function setFakeFrom($name, $email)
{
$this->fakeFromName = $name;
$this->fakeFromEmail = $email;
return $this;
} | php | {
"resource": ""
} |
q256544 | WinCacheClassLoader.findFile | test | public function findFile($class)
{
$file = wincache_ucache_get($this->prefix.$class, $success);
if (!$success) {
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null, 0);
}
return $file;
} | php | {
"resource": ""
} |
q256545 | ApcClassLoader.findFile | test | public function findFile($class)
{
$file = apcu_fetch($this->prefix.$class, $success);
if (!$success) {
apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class) ?: null);
}
return $file;
} | php | {
"resource": ""
} |
q256546 | ClassCollectionLoader.load | test | public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
{
// each $name can only be loaded once per PHP process
if (isset(self::$loaded[$name])) {
return;
}
self::$loaded[$name] = true;
if ($adaptive) {
... | php | {
"resource": ""
} |
q256547 | ClassCollectionLoader.fixNamespaceDeclarations | test | public static function fixNamespaceDeclarations($source)
{
if (!function_exists('token_get_all') || !self::$useTokenizer) {
if (preg_match('/(^|\s)namespace(.*?)\s*;/', $source)) {
$source = preg_replace('/(^|\s)namespace(.*?)\s*;/', "$1namespace$2\n{", $source)."}\n";
... | php | {
"resource": ""
} |
q256548 | ClassCollectionLoader.writeCacheFile | test | private static function writeCacheFile($file, $content)
{
$dir = dirname($file);
if (!is_writable($dir)) {
throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir));
}
$tmpFile = tempnam($dir, basename($file));
if (false !== @file_put_c... | php | {
"resource": ""
} |
q256549 | ClassCollectionLoader.getOrderedClasses | test | private static function getOrderedClasses(array $classes)
{
$map = array();
self::$seen = array();
foreach ($classes as $class) {
try {
$reflectionClass = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
throw new \Inva... | php | {
"resource": ""
} |
q256550 | ClassLoader.addPrefixes | test | public function addPrefixes(array $prefixes)
{
foreach ($prefixes as $prefix => $path) {
$this->addPrefix($prefix, $path);
}
} | php | {
"resource": ""
} |
q256551 | ClassLoader.addPrefix | test | public function addPrefix($prefix, $paths)
{
if (!$prefix) {
foreach ((array) $paths as $path) {
$this->fallbackDirs[] = $path;
}
return;
}
if (isset($this->prefixes[$prefix])) {
if (is_array($paths)) {
$this->p... | php | {
"resource": ""
} |
q256552 | XcacheClassLoader.findFile | test | public function findFile($class)
{
if (xcache_isset($this->prefix.$class)) {
$file = xcache_get($this->prefix.$class);
} else {
$file = $this->decorated->findFile($class) ?: null;
xcache_set($this->prefix.$class, $file);
}
return $file;
} | php | {
"resource": ""
} |
q256553 | Parser.parse | test | public function parse($text)
{
$this->prepare();
if (ltrim($text) === '') {
return '';
}
$text = str_replace(["\r\n", "\n\r", "\r"], "\n", $text);
$this->prepareMarkers($text);
$absy = $this->parseBlocks(explode("\n", $text));
$markup = $this->renderAbsy($absy);
$this->cleanup();
return $mark... | php | {
"resource": ""
} |
q256554 | Parser.detectLineType | test | protected function detectLineType($lines, $current)
{
$line = $lines[$current];
$blockTypes = $this->blockTypes();
foreach($blockTypes as $blockType) {
if ($this->{'identify' . $blockType}($line, $lines, $current)) {
return $blockType;
}
}
// consider the line a normal paragraph if no other block t... | php | {
"resource": ""
} |
q256555 | Parser.parseBlock | test | protected function parseBlock($lines, $current)
{
// identify block type for this line
$blockType = $this->detectLineType($lines, $current);
// call consume method for the detected block type to consume further lines
return $this->{'consume' . $blockType}($lines, $current);
} | php | {
"resource": ""
} |
q256556 | Parser.inlineMarkers | test | protected function inlineMarkers()
{
$markers = [];
// detect "parse" functions
$reflection = new \ReflectionClass($this);
foreach($reflection->getMethods(ReflectionMethod::IS_PROTECTED) as $method) {
$methodName = $method->getName();
if (strncmp($methodName, 'parse', 5) === 0) {
preg_match_all('/@ma... | php | {
"resource": ""
} |
q256557 | Parser.prepareMarkers | test | protected function prepareMarkers($text)
{
$this->_inlineMarkers = [];
foreach ($this->inlineMarkers() as $marker => $method) {
if (strpos($text, $marker) !== false) {
$m = $marker[0];
// put the longest marker first
if (isset($this->_inlineMarkers[$m])) {
reset($this->_inlineMarkers[$m]);
... | php | {
"resource": ""
} |
q256558 | Parser.parseInline | test | protected function parseInline($text)
{
if ($this->_depth >= $this->maximumNestingLevel) {
// maximum depth is reached, do not parse input
return [['text', $text]];
}
$this->_depth++;
$markers = implode('', array_keys($this->_inlineMarkers));
$paragraph = [];
while (!empty($markers) && ($found = s... | php | {
"resource": ""
} |
q256559 | EmphStrongTrait.parseEmphStrong | test | protected function parseEmphStrong($text)
{
$marker = $text[0];
if (!isset($text[1])) {
return [['text', $text[0]], 1];
}
if ($marker == $text[1]) { // strong
// work around a PHP bug that crashes with a segfault on too much regex backtrack
// check whether the end marker exists in the text
// ht... | php | {
"resource": ""
} |
q256560 | HtmlTrait.identifyHtml | test | protected function identifyHtml($line, $lines, $current)
{
if ($line[0] !== '<' || isset($line[1]) && $line[1] == ' ') {
return false; // no html tag
}
if (strncmp($line, '<!--', 4) === 0) {
return true; // a html comment
}
$gtPos = strpos($lines[$current], '>');
$spacePos = strpos($lines[$current]... | php | {
"resource": ""
} |
q256561 | HtmlTrait.consumeHtml | test | protected function consumeHtml($lines, $current)
{
$content = [];
if (strncmp($lines[$current], '<!--', 4) === 0) { // html comment
for ($i = $current, $count = count($lines); $i < $count; $i++) {
$line = $lines[$i];
$content[] = $line;
if (strpos($line, '-->') !== false) {
break;
}
}
... | php | {
"resource": ""
} |
q256562 | FencedCodeTrait.identifyFencedCode | test | protected function identifyFencedCode($line)
{
return ($line[0] === '`' && strncmp($line, '```', 3) === 0) ||
($line[0] === '~' && strncmp($line, '~~~', 3) === 0) ||
(isset($line[3]) && (
($line[3] === '`' && strncmp(ltrim($line), '```', 3) === 0) ||
($line[3] === '~' && strncmp(ltrim($line), '... | php | {
"resource": ""
} |
q256563 | HeadlineTrait.identifyHeadline | test | protected function identifyHeadline($line, $lines, $current)
{
return (
// heading with #
$line[0] === '#' && !preg_match('/^#\d+/', $line)
||
// underlined headline
!empty($lines[$current + 1]) &&
(($l = $lines[$current + 1][0]) === '=' || $l === '-') &&
preg_match('/^(\-+|=+)\s*$/', $lines[$cu... | php | {
"resource": ""
} |
q256564 | HeadlineTrait.consumeHeadline | test | protected function consumeHeadline($lines, $current)
{
if ($lines[$current][0] === '#') {
// ATX headline
$level = 1;
while (isset($lines[$current][$level]) && $lines[$current][$level] === '#' && $level < 6) {
$level++;
}
$block = [
'headline',
'content' => $this->parseInline(trim($lines[$... | php | {
"resource": ""
} |
q256565 | LinkTrait.replaceEscape | test | protected function replaceEscape($text)
{
$strtr = [];
foreach($this->escapeCharacters as $char) {
$strtr["\\$char"] = $char;
}
return strtr($text, $strtr);
} | php | {
"resource": ""
} |
q256566 | LinkTrait.parseLink | test | protected function parseLink($markdown)
{
if (!in_array('parseLink', array_slice($this->context, 1)) && ($parts = $this->parseLinkOrImage($markdown)) !== false) {
list($text, $url, $title, $offset, $key) = $parts;
return [
[
'link',
'text' => $this->parseInline($text),
'url' => $url,
't... | php | {
"resource": ""
} |
q256567 | LinkTrait.parseImage | test | protected function parseImage($markdown)
{
if (($parts = $this->parseLinkOrImage(substr($markdown, 1))) !== false) {
list($text, $url, $title, $offset, $key) = $parts;
return [
[
'image',
'text' => $text,
'url' => $url,
'title' => $title,
'refkey' => $key,
'orig' => substr($m... | php | {
"resource": ""
} |
q256568 | CodeTrait.parseInlineCode | test | protected function parseInlineCode($text)
{
if (preg_match('/^(``+)\s(.+?)\s\1/s', $text, $matches)) { // code with enclosed backtick
return [
[
'inlineCode',
$matches[2],
],
strlen($matches[0])
];
} elseif (preg_match('/^`(.+?)`/s', $text, $matches)) {
return [
[
'inlineCod... | php | {
"resource": ""
} |
q256569 | CodeTrait.consumeCode | test | protected function consumeCode($lines, $current)
{
// consume until newline
$content = [];
for ($i = $current, $count = count($lines); $i < $count; $i++) {
$line = $lines[$i];
// a line is considered to belong to this code block as long as it is intended by 4 spaces or a tab
if (isset($line[0]) && ($l... | php | {
"resource": ""
} |
q256570 | ListTrait.identifyUl | test | protected function identifyUl($line)
{
$l = $line[0];
return ($l === '-' || $l === '+' || $l === '*') && (isset($line[1]) && (($l1 = $line[1]) === ' ' || $l1 === "\t")) ||
($l === ' ' && preg_match('/^ {0,3}[\-\+\*][ \t]/', $line));
} | php | {
"resource": ""
} |
q256571 | ListTrait.renderList | test | protected function renderList($block)
{
$type = $block['list'];
if (!empty($block['attr'])) {
$output = "<$type " . $this->generateHtmlAttributes($block['attr']) . ">\n";
} else {
$output = "<$type>\n";
}
foreach ($block['items'] as $item => $itemLines) {
$output .= '<li>' . $this->renderAbsy($ite... | php | {
"resource": ""
} |
q256572 | QuoteTrait.consumeQuote | test | protected function consumeQuote($lines, $current)
{
// consume until newline
$content = [];
for ($i = $current, $count = count($lines); $i < $count; $i++) {
$line = $lines[$i];
if (ltrim($line) !== '') {
if ($line[0] == '>' && !isset($line[1])) {
$line = '';
} elseif (strncmp($line, '> ', 2) =... | php | {
"resource": ""
} |
q256573 | MarkdownExtra.consumeReference | test | protected function consumeReference($lines, $current)
{
while (isset($lines[$current]) && preg_match('/^ {0,3}\[(.+?)\]:\s*(.+?)(?:\s+[\(\'"](.+?)[\)\'"])?\s*('.$this->_specialAttributesRegex.')?\s*$/', $lines[$current], $matches)) {
$label = strtolower($matches[1]);
$this->references[$label] = [
'url' =>... | php | {
"resource": ""
} |
q256574 | MarkdownExtra.renderHeadline | test | protected function renderHeadline($block)
{
foreach($block['content'] as $i => $element) {
if ($element[0] === 'specialAttributes') {
unset($block['content'][$i]);
$block['attributes'] = $element[1];
}
}
$tag = 'h' . $block['level'];
$attributes = $this->renderAttributes($block);
return "<$tag$... | php | {
"resource": ""
} |
q256575 | StrikeoutTrait.parseStrike | test | protected function parseStrike($markdown)
{
if (preg_match('/^~~(.+?)~~/', $markdown, $matches)) {
return [
[
'strike',
$this->parseInline($matches[1])
],
strlen($matches[0])
];
}
return [['text', $markdown[0] . $markdown[1]], 2];
} | php | {
"resource": ""
} |
q256576 | TableTrait.identifyTable | test | protected function identifyTable($line, $lines, $current)
{
return strpos($line, '|') !== false && isset($lines[$current + 1])
&& preg_match('~^\\s*\\|?(\\s*:?-[\\-\\s]*:?\\s*\\|?)*\\s*$~', $lines[$current + 1])
&& strpos($lines[$current + 1], '|') !== false
&& isset($lines[$current + 2]) && trim($lines[$cu... | php | {
"resource": ""
} |
q256577 | TableTrait.consumeTable | test | protected function consumeTable($lines, $current)
{
// consume until newline
$block = [
'table',
'cols' => [],
'rows' => [],
];
for ($i = $current, $count = count($lines); $i < $count; $i++) {
$line = trim($lines[$i]);
// extract alignment from second line
if ($i == $current+1) {
$cols ... | php | {
"resource": ""
} |
q256578 | TableTrait.renderTable | test | protected function renderTable($block)
{
$head = '';
$body = '';
$cols = $block['cols'];
$first = true;
foreach($block['rows'] as $row) {
$cellTag = $first ? 'th' : 'td';
$tds = '';
foreach ($row as $c => $cell) {
$align = empty($cols[$c]) ? '' : ' align="' . $cols[$c] . '"';
$tds .= "<$cell... | php | {
"resource": ""
} |
q256579 | UrlLinkTrait.parseUrl | test | protected function parseUrl($markdown)
{
$pattern = <<<REGEXP
/(?(R) # in case of recursion match parentheses
\(((?>[^\s()]+)|(?R))*\)
| # else match a link with title
^(https?|ftp):\/\/(([^\s<>()]+)|(?R))+(?<![\.,:;\'"!\?\s])
)/x
REGEXP;
if (!in_array('parseLink', $this->context) && preg_m... | php | {
"resource": ""
} |
q256580 | Assertion.equals | test | public function equals($nameId, $format)
{
if (false == $this->getSubject()) {
return false;
}
if (false == $this->getSubject()->getNameID()) {
return false;
}
if ($this->getSubject()->getNameID()->getValue() != $nameId) {
return false;
... | php | {
"resource": ""
} |
q256581 | XMLHelper.createElement | test | public static function createElement(DOMDocument $document, $name, array $attributes = []): DOMElement
{
$element = $document->createElement($name);
foreach ($attributes as $attribName => $attribValue) {
$element->setAttribute($attribName, $attribValue);
}
return $eleme... | php | {
"resource": ""
} |
q256582 | XMLHelper.createElementWithText | test | public static function createElementWithText(
DOMDocument $document,
string $name,
string $text,
array $attributes = []
): DOMElement {
$element = self::createElement($document, $name, $attributes);
$wrappedText = $document->createCDATASection($text);
$element... | php | {
"resource": ""
} |
q256583 | XMLItem.validateImages | test | private static function validateImages(array $images): bool
{
$valid = false;
foreach ($images as $image) {
if ($image->getType() === Image::TYPE_DEFAULT) {
$valid = true;
break;
}
}
if (!$valid) {
throw new BaseIm... | php | {
"resource": ""
} |
q256584 | DataHelper.checkForEmptyValue | test | public static function checkForEmptyValue(string $valueName, $value): string
{
$value = trim($value);
if ($value === '') {
throw new EmptyValueNotAllowedException($valueName);
}
return $value;
} | php | {
"resource": ""
} |
q256585 | DataHelper.checkForIllegalCsvPropertyKeys | test | public static function checkForIllegalCsvPropertyKeys(string $propertyKey): void
{
if (strpos($propertyKey, "\t") !== false || strpos($propertyKey, "\n") !== false) {
throw new BadPropertyKeyException($propertyKey);
}
} | php | {
"resource": ""
} |
q256586 | Exporter.create | test | public static function create(int $type, int $itemsPerPage = 20, array $csvProperties = []): Exporter
{
if ($itemsPerPage < 1) {
throw new InvalidArgumentException('At least one item must be exported per page.');
}
switch ($type) {
case self::TYPE_XML:
... | php | {
"resource": ""
} |
q256587 | Property.addValue | test | public function addValue(string $value, ?string $usergroup = null): void
{
if (array_key_exists($usergroup, $this->getAllValues())) {
throw new DuplicateValueForUsergroupException($this->getKey(), $usergroup);
}
$this->values[$usergroup] = DataHelper::checkForEmptyValue('propert... | php | {
"resource": ""
} |
q256588 | Page.validateWithSchema | test | private function validateWithSchema(DOMDocument $document): void
{
$validationErrors = [];
set_error_handler(function (/** @noinspection PhpUnusedParameterInspection */ $errno, $errstr)
use (&$validationErrors) {
array_push($validationErrors, $errstr);
});
$isValid = $d... | php | {
"resource": ""
} |
q256589 | Item.addName | test | public function addName(string $name, string $usergroup = ''): void
{
$this->name->setValue($name, $usergroup);
} | php | {
"resource": ""
} |
q256590 | Item.addSummary | test | public function addSummary(string $summary, string $usergroup = ''): void
{
$this->summary->setValue($summary, $usergroup);
} | php | {
"resource": ""
} |
q256591 | Item.addDescription | test | public function addDescription(string $description, string $usergroup = ''): void
{
$this->description->setValue($description, $usergroup);
} | php | {
"resource": ""
} |
q256592 | Item.addPrice | test | public function addPrice($price, $usergroup = ''): void
{
if ($this->price === null) {
$this->price = new Price();
}
$this->price->setValue($price, $usergroup);
} | php | {
"resource": ""
} |
q256593 | Item.addBonus | test | public function addBonus(float $bonus, string $usergroup = ''): void
{
$this->bonus->setValue($bonus, $usergroup);
} | php | {
"resource": ""
} |
q256594 | Item.addSalesFrequency | test | public function addSalesFrequency(int $salesFrequency, string $usergroup = ''): void
{
$this->salesFrequency->setValue($salesFrequency, $usergroup);
} | php | {
"resource": ""
} |
q256595 | Item.addDateAdded | test | public function addDateAdded(DateTime $dateAdded, string $usergroup = ''): void
{
$this->dateAdded->setDateValue($dateAdded, $usergroup);
} | php | {
"resource": ""
} |
q256596 | Item.addSort | test | public function addSort(int $sort, string $usergroup = ''): void
{
$this->sort->setValue($sort, $usergroup);
} | php | {
"resource": ""
} |
q256597 | UsergroupAwareSimpleValue.validate | test | protected function validate($value)
{
$value = trim($value);
if ($value === '') {
throw new EmptyValueNotAllowedException($this->getValueName());
}
return $value;
} | php | {
"resource": ""
} |
q256598 | Hooks.get | test | public function get($name)
{
if (!$this->has($name)) {
throw new InvalidArgumentException(sprintf('Hook named "%s" is not present', $name));
}
return file_get_contents($this->getPath($name));
} | php | {
"resource": ""
} |
q256599 | Hooks.setSymlink | test | public function setSymlink($name, $file)
{
if ($this->has($name)) {
throw new LogicException(sprintf('A hook "%s" is already defined', $name));
}
$path = $this->getPath($name);
if (false === symlink($file, $path)) {
throw new RuntimeException(sprintf('Unable ... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.