_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);
} else {
$this->templates = $this->getTemplatesFromString($template);
}
} elseif ($this->templates === null) {
$this->templates[] = $this->twig->loadTemplate(static::DEFAULT_TEMPLATE);
} else {
throw new \Exception('Unable to load template');
}
return $this;
} | 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($item, $itemType);
}
);
}
return $items;
} | 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->userRepository->getUserByUserInfo($profile);
if ($auth0User) {
// If we have a user, we are going to log them in, but if
// there is an onLogin defined we need to allow the Laravel developer
// to implement the user as they want an also let them store it.
if ($service->hasOnLogin()) {
$user = $service->callOnLogin($auth0User);
} else {
// If not, the user will be fine
$user = $auth0User;
}
\Auth::login($user, $service->rememberUser());
}
return \Redirect::intended('/');
} | 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')) {
return iconv_substr($string, $start, $end ?: iconv_strlen($string), static::getEncoding());
}
return false;
} | 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_getInvocationMocker()->addMatcher(new DefaultArgumentRemover());
$functionMockBuilder = new MockBuilder();
$functionMockBuilder->setNamespace($namespace)
->setName($name)
->setFunctionProvider($mock);
$functionMock = $functionMockBuilder->build();
$functionMock->enable();
$this->registerForTearDown($functionMock);
$proxy = new MockObjectProxy($mock);
return $proxy;
} | 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 () {
})
->build()
->define();
} | 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 = strtolower(substr($locale, 3));
}
return $code;
} | 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 ($language['short'] != $short) {
continue;
}
$long = $language['long'];
}
return $long;
} | 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();
} else {
$request->session()->put('locale', $locale);
}
} | 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) {
$previous_url = substr($previous_url, 3);
} else {
$previous_url = substr($previous_url, strrpos($previous_url, '/') + 1);
}
$url = rtrim(env('APP_URL'), '/') . '/' . $locale . '/' . ltrim($previous_url, '/');
$session->setPreviousUrl($url);
}
return redirect($session->previousUrl());
} | 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('language.carbon')) {
// Carbon uses only language code
if (config('language.mode.code') == 'long') {
$locale = explode('-', $locale)[0];
}
\Carbon\Carbon::setLocale($locale);
}
// Set date language
if (config('language.date')) {
// Date uses only language code
if (config('language.mode.code') == 'long') {
$locale = explode('-', $locale)[0];
}
\Date::setLocale($locale);
}
} | 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]);
$this->elements = array_values($this->elements);
return $element;
} | 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];
}
return $this->createNew($newElements);
} | 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 === 'tlsv1.2') {
$this->starttls()
->ehlo();
}
if ($this->username !== null || $this->password !== null) {
$this->authLogin();
} elseif ($this->oauthToken !== null) {
$this->authOAuthBearer();
}
$this->mailFrom()
->rcptTo()
->data()
->quit();
return fclose($this->smtp);
} | 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_blocking($this->smtp, 1);
if (!$this->smtp){
throw new SMTPException("Could not open SMTP Port.");
}
$code = $this->getCode();
if ($code !== '220'){
throw new CodeException('220', $code, array_pop($this->resultStack));
}
return $this;
} | 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', '<')) {
throw new CryptoException('Crypto type expected PHP 5.6 or greater');
}
switch ($this->secure) {
case 'tlsv1.0':
$crypto_type = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT;
break;
case 'tlsv1.1':
$crypto_type = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
break;
case 'tlsv1.2':
$crypto_type = STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
break;
default:
$crypto_type = STREAM_CRYPTO_METHOD_TLS_CLIENT;
break;
}
if(!\stream_socket_enable_crypto($this->smtp, true, $crypto_type)) {
throw new CryptoException("Start TLS failed to enable crypto");
}
return $this;
} | 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 = $this->pushStack($in);
if ($code !== '334'){
throw new CodeException('334', $code, array_pop($this->resultStack));
}
$in = base64_encode($this->password) . $this->CRLF;
$code = $this->pushStack($in);
if ($code !== '235'){
throw new CodeException('235', $code, array_pop($this->resultStack));
}
return $this;
} | 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(1),
chr(1)
);
$authStr = base64_encode($authStr);
$in = "AUTH OAUTHBEARER $authStr" . $this->CRLF;
$code = $this->pushStack($in);
if ($code !== '235'){
throw new CodeException('235', $code, array_pop($this->resultStack));
}
return $this;
} | 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 $authStr" . $this->CRLF;
$code = $this->pushStack($in);
if ($code !== '235'){
throw new CodeException('235', $code, array_pop($this->resultStack));
}
return $this;
} | 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->pushStack($in);
if ($code !== '250') {
throw new CodeException('250', $code, array_pop($this->resultStack));
}
}
return $this;
} | 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);
if ($code !== '250'){
throw new CodeException('250', $code, array_pop($this->resultStack));
}
return $this;
} | 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;
}
}
throw new SMTPException("SMTP Server did not respond with anything I recognized");
} | 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) {
$declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
// don't include already declared classes
$classes = array_diff($classes, $declared);
// the cache is different depending on which classes are already declared
$name = $name.'-'.substr(hash('sha256', implode('|', $classes)), 0, 5);
}
$classes = array_unique($classes);
// cache the core classes
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
}
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.DIRECTORY_SEPARATOR);
$cache = $cacheDir.'/'.$name.$extension;
// auto-reload
$reload = false;
if ($autoReload) {
$metadata = $cache.'.meta';
if (!is_file($metadata) || !is_file($cache)) {
$reload = true;
} else {
$time = filemtime($cache);
$meta = unserialize(file_get_contents($metadata));
sort($meta[1]);
sort($classes);
if ($meta[1] != $classes) {
$reload = true;
} else {
foreach ($meta[0] as $resource) {
if (!is_file($resource) || filemtime($resource) > $time) {
$reload = true;
break;
}
}
}
}
}
if (!$reload && file_exists($cache)) {
require_once $cache;
return;
}
if (!$adaptive) {
$declared = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
}
$files = self::inline($classes, $cache, $declared);
if ($autoReload) {
// save the resources
self::writeCacheFile($metadata, serialize(array(array_values($files), $classes)));
}
} | 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";
}
return $source;
}
$rawChunk = '';
$output = '';
$inNamespace = false;
$tokens = token_get_all($source);
for ($i = 0; isset($tokens[$i]); ++$i) {
$token = $tokens[$i];
if (!isset($token[1]) || 'b"' === $token) {
$rawChunk .= $token;
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
// strip comments
continue;
} elseif (T_NAMESPACE === $token[0]) {
if ($inNamespace) {
$rawChunk .= "}\n";
}
$rawChunk .= $token[1];
// namespace name and whitespaces
while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
$rawChunk .= $tokens[$i][1];
}
if ('{' === $tokens[$i]) {
$inNamespace = false;
--$i;
} else {
$rawChunk = rtrim($rawChunk)."\n{";
$inNamespace = true;
}
} elseif (T_START_HEREDOC === $token[0]) {
$output .= self::compressCode($rawChunk).$token[1];
do {
$token = $tokens[++$i];
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
} while (T_END_HEREDOC !== $token[0]);
$output .= "\n";
$rawChunk = '';
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {
$output .= self::compressCode($rawChunk).$token[1];
$rawChunk = '';
} else {
$rawChunk .= $token[1];
}
}
if ($inNamespace) {
$rawChunk .= "}\n";
}
$output .= self::compressCode($rawChunk);
if (\PHP_VERSION_ID >= 70000) {
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
unset($tokens, $rawChunk);
gc_mem_caches();
}
return $output;
} | 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_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
@chmod($file, 0666 & ~umask());
return;
}
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
} | 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 \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
}
$map = array_merge($map, self::getClassHierarchy($reflectionClass));
}
return $map;
} | 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->prefixes[$prefix] = array_unique(array_merge(
$this->prefixes[$prefix],
$paths
));
} elseif (!in_array($paths, $this->prefixes[$prefix])) {
$this->prefixes[$prefix][] = $paths;
}
} else {
$this->prefixes[$prefix] = array_unique((array) $paths);
}
} | 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 $markup;
} | 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 type matches
return 'paragraph';
} | 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('/@marker ([^\s]+)/', $method->getDocComment(), $matches);
foreach($matches[1] as $match) {
$markers[$match] = $methodName;
}
}
}
return $markers;
} | 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]);
if (strlen($marker) > strlen(key($this->_inlineMarkers[$m]))) {
$this->_inlineMarkers[$m] = array_merge([$marker => $method], $this->_inlineMarkers[$m]);
continue;
}
}
$this->_inlineMarkers[$m][$marker] = $method;
}
}
} | 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 = strpbrk($text, $markers)) !== false) {
$pos = strpos($text, $found);
// add the text up to next marker to the paragraph
if ($pos !== 0) {
$paragraph[] = ['text', substr($text, 0, $pos)];
}
$text = $found;
$parsed = false;
foreach ($this->_inlineMarkers[$text[0]] as $marker => $method) {
if (strncmp($text, $marker, strlen($marker)) === 0) {
// parse the marker
array_unshift($this->context, $method);
list($output, $offset) = $this->$method($text);
array_shift($this->context);
$paragraph[] = $output;
$text = substr($text, $offset);
$parsed = true;
break;
}
}
if (!$parsed) {
$paragraph[] = ['text', substr($text, 0, 1)];
$text = substr($text, 1);
}
}
$paragraph[] = ['text', $text];
$this->_depth--;
return $paragraph;
} | 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
// https://github.com/erusev/parsedown/issues/443
// https://bugs.php.net/bug.php?id=45735
if (strpos($text, $marker . $marker, 2) === false) {
return [['text', $text[0] . $text[1]], 2];
}
if ($marker === '*' && preg_match('/^[*]{2}((?>\\\\[*]|[^*]|[*][^*]*[*])+?)[*]{2}/s', $text, $matches) ||
$marker === '_' && preg_match('/^__((?>\\\\_|[^_]|_[^_]*_)+?)__/us', $text, $matches)) {
return [
[
'strong',
$this->parseInline($matches[1]),
],
strlen($matches[0])
];
}
} else { // emph
// work around a PHP bug that crashes with a segfault on too much regex backtrack
// check whether the end marker exists in the text
// https://github.com/erusev/parsedown/issues/443
// https://bugs.php.net/bug.php?id=45735
if (strpos($text, $marker, 1) === false) {
return [['text', $text[0]], 1];
}
if ($marker === '*' && preg_match('/^[*]((?>\\\\[*]|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*][^*])/s', $text, $matches) ||
$marker === '_' && preg_match('/^_((?>\\\\_|[^_]|__[^_]*__)+?)_(?!_[^_])\b/us', $text, $matches)) {
// if only a single whitespace or nothing is contained in an emphasis, do not consider it valid
if ($matches[1] === '' || $matches[1] === ' ') {
return [['text', $text[0]], 1];
}
return [
[
'emph',
$this->parseInline($matches[1]),
],
strlen($matches[0])
];
}
}
return [['text', $text[0]], 1];
} | 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], ' ');
if ($gtPos === false && $spacePos === false) {
return false; // no html tag
} elseif ($spacePos === false) {
$tag = rtrim(substr($line, 1, $gtPos - 1), '/');
} else {
$tag = rtrim(substr($line, 1, min($gtPos, $spacePos) - 1), '/');
}
if (!ctype_alnum($tag) || in_array(strtolower($tag), $this->inlineHtmlElements)) {
return false; // no html tag or inline html tag
}
return true;
} | 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;
}
}
} else {
$tag = rtrim(substr($lines[$current], 1, min(strpos($lines[$current], '>'), strpos($lines[$current] . ' ', ' ')) - 1), '/');
$level = 0;
if (in_array($tag, $this->selfClosingHtmlElements)) {
$level--;
}
for ($i = $current, $count = count($lines); $i < $count; $i++) {
$line = $lines[$i];
$content[] = $line;
$level += substr_count($line, "<$tag") - substr_count($line, "</$tag>") - substr_count($line, "/>");
if ($level <= 0) {
break;
}
}
}
$block = [
'html',
'content' => implode("\n", $content),
];
return [$block, $i];
} | 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), '~~~', 3) === 0)
));
} | 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[$current + 1])
);
} | 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[$current], "# \t")),
'level' => $level,
];
return [$block, $current];
} else {
// underlined headline
$block = [
'headline',
'content' => $this->parseInline($lines[$current]),
'level' => $lines[$current + 1][0] === '=' ? 1 : 2,
];
return [$block, $current + 1];
}
} | 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,
'title' => $title,
'refkey' => $key,
'orig' => substr($markdown, 0, $offset),
],
$offset
];
} else {
// remove all starting [ markers to avoid next one to be parsed as link
$result = '[';
$i = 1;
while (isset($markdown[$i]) && $markdown[$i] === '[') {
$result .= '[';
$i++;
}
return [['text', $result], $i];
}
} | 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($markdown, 0, $offset + 1),
],
$offset + 1
];
} else {
// remove all starting [ markers to avoid next one to be parsed as link
$result = '!';
$i = 1;
while (isset($markdown[$i]) && $markdown[$i] === '[') {
$result .= '[';
$i++;
}
return [['text', $result], $i];
}
} | 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 [
[
'inlineCode',
$matches[1],
],
strlen($matches[0])
];
}
return [['text', $text[0]], 1];
} | 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]) && ($line[0] === "\t" || strncmp($line, ' ', 4) === 0)) {
$line = $line[0] === "\t" ? substr($line, 1) : substr($line, 4);
$content[] = $line;
// but also if it is empty and the next line is intended by 4 spaces or a tab
} elseif (($line === '' || rtrim($line) === '') && isset($lines[$i + 1][0]) &&
($lines[$i + 1][0] === "\t" || strncmp($lines[$i + 1], ' ', 4) === 0)) {
if ($line !== '') {
$line = $line[0] === "\t" ? substr($line, 1) : substr($line, 4);
}
$content[] = $line;
} else {
break;
}
}
$block = [
'code',
'content' => implode("\n", $content),
];
return [$block, --$i];
} | 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($itemLines). "</li>\n";
}
return $output . "</$type>\n";
} | 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) === 0) {
$line = substr($line, 2);
}
$content[] = $line;
} else {
break;
}
}
$block = [
'quote',
'content' => $this->parseBlocks($content),
'simple' => true,
];
return [$block, $i];
} | 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' => $this->replaceEscape($matches[2]),
];
if (isset($matches[3])) {
$this->references[$label]['title'] = $matches[3];
} else {
// title may be on the next line
if (isset($lines[$current + 1]) && preg_match('/^\s+[\(\'"](.+?)[\)\'"]\s*$/', $lines[$current + 1], $matches)) {
$this->references[$label]['title'] = $matches[1];
$current++;
}
}
if (isset($matches[5])) {
$this->references[$label]['attributes'] = $matches[5];
}
$current++;
}
return [false, --$current];
} | 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$attributes>" . rtrim($this->renderAbsy($block['content']), "# \t") . "</$tag>\n";
} | 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[$current + 1]) !== '';
} | 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 = explode('|', trim($line, ' |'));
foreach($cols as $col) {
$col = trim($col);
if (empty($col)) {
$block['cols'][] = '';
continue;
}
$l = ($col[0] === ':');
$r = (substr($col, -1, 1) === ':');
if ($l && $r) {
$block['cols'][] = 'center';
} elseif ($l) {
$block['cols'][] = 'left';
} elseif ($r) {
$block['cols'][] = 'right';
} else {
$block['cols'][] = '';
}
}
continue;
}
if ($line === '' || substr($lines[$i], 0, 4) === ' ') {
break;
}
if ($line[0] === '|') {
$line = substr($line, 1);
}
if (substr($line, -1, 1) === '|' && (substr($line, -2, 2) !== '\\|' || substr($line, -3, 3) === '\\\\|')) {
$line = substr($line, 0, -1);
}
array_unshift($this->context, 'table');
$row = $this->parseInline($line);
array_shift($this->context);
$r = count($block['rows']);
$c = 0;
$block['rows'][] = [];
foreach ($row as $absy) {
if (!isset($block['rows'][$r][$c])) {
$block['rows'][$r][] = [];
}
if ($absy[0] === 'tableBoundary') {
$c++;
} else {
$block['rows'][$r][$c][] = $absy;
}
}
}
return [$block, --$i];
} | 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 .= "<$cellTag$align>" . trim($this->renderAbsy($cell)) . "</$cellTag>";
}
if ($first) {
$head .= "<tr>$tds</tr>\n";
} else {
$body .= "<tr>$tds</tr>\n";
}
$first = false;
}
return $this->composeTable($head, $body);
} | 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_match($pattern, $markdown, $matches)) {
return [
['autoUrl', $matches[0]],
strlen($matches[0])
];
}
return [['text', substr($markdown, 0, 4)], 4];
} | 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;
}
if ($this->getSubject()->getNameID()->getFormat() != $format) {
return false;
}
return true;
} | 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 $element;
} | 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->appendChild($wrappedText);
return $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 BaseImageMissingException();
}
return $valid;
} | 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:
$exporter = new XMLExporter($itemsPerPage);
break;
case self::TYPE_CSV:
$exporter = new CSVExporter($itemsPerPage, $csvProperties);
break;
default:
throw new InvalidArgumentException('Unsupported exporter type.');
}
return $exporter;
} | 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('propertyValue', $value);
} | 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 = $document->schemaValidate(Constant::$XSD_SCHEMA_PATH);
restore_error_handler();
if (!$isValid) {
throw new XMLSchemaViolationException($validationErrors);
}
} | 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 to create hook "%s"', $name, $path));
}
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.