_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q263000 | ErrorHandler.addTransformer | test | public function addTransformer(TransformerContract $transformer): HandlerContract
{
$this->transformers[\get_class($transformer)] = $transformer;
return $this;
} | php | {
"resource": ""
} |
q263001 | ErrorHandler.handleError | test | public function handleError(int $type, string $message, string $file = '', int $line = 0): bool
{
if (\error_reporting() === 0) {
return false;
}
// Level is the current error reporting level to manage silent error.
// Strong errors are not authorized to be silenced.
$severity = \error_reporting() | \E_RECOVERABLE_ERROR | \E_USER_ERROR | \E_DEPRECATED | \E_USER_DEPRECATED;
if ($severity) {
throw new FatalErrorException($message, 0, $severity, $file, $line);
}
return true;
} | php | {
"resource": ""
} |
q263002 | ErrorHandler.handleShutdown | test | public function handleShutdown(): void
{
if ($this->reservedMemory === null) {
return;
}
$this->reservedMemory = null;
// If an error has occurred that has not been displayed, we will create a fatal
// error exception instance and pass it into the regular exception handling
// code so it can be displayed back out to the developer for information.
$error = \error_get_last();
$exception = null;
if ($error !== null && self::isLevelFatal($error['type'])) {
$trace = $error['backtrace'] ?? null;
if (\strpos($error['message'], 'Allowed memory') === 0 || \strpos($error['message'], 'Out of memory') === 0) {
$exception = new OutOfMemoryException(self::$levels[$error['type']] . ': ' . $error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
} else {
// Create a new fatal exception instance from an error array.
$exception = new FatalErrorException(self::$levels[$error['type']] . ': ' . $error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
}
}
if ($exception !== null) {
$this->handleException($exception);
}
} | php | {
"resource": ""
} |
q263003 | ErrorHandler.registerExceptionHandler | test | protected function registerExceptionHandler(): void
{
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
\ini_set('display_errors', '0');
} elseif (! \filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || \filter_var(\ini_get('error_log'), \FILTER_VALIDATE_BOOLEAN)) {
// CLI - display errors only if they're not already logged to STDERR
\ini_set('display_errors', '1');
}
\set_exception_handler([$this, 'handleException']);
} | php | {
"resource": ""
} |
q263004 | ErrorHandler.registerShutdownHandler | test | protected function registerShutdownHandler(): void
{
if ($this->reservedMemory === null) {
$this->reservedMemory = \str_repeat('x', 10240);
\register_shutdown_function([$this, 'handleShutdown']);
}
} | php | {
"resource": ""
} |
q263005 | ErrorHandler.prepareException | test | protected function prepareException($exception)
{
if (! $exception instanceof Exception && ! $exception instanceof Error) {
$exception = new FatalThrowableError($exception);
} elseif ($exception instanceof Error) {
$trace = $exception->getTrace();
$exception = new FatalErrorException(
$exception->getMessage(),
$exception->getCode(),
\E_ERROR,
$exception->getFile(),
$exception->getLine(),
\count($trace),
\count($trace) !== 0,
$trace
);
}
return $exception;
} | php | {
"resource": ""
} |
q263006 | ErrorHandler.getTransformed | test | protected function getTransformed(Throwable $exception): Throwable
{
if (! $exception instanceof OutOfMemoryException || \count($this->transformers) === 0) {
return $exception;
}
foreach ($this->transformers as $transformer) {
/** @var TransformerContract $transformer */
$exception = $transformer->transform($exception);
}
return $exception;
} | php | {
"resource": ""
} |
q263007 | ErrorHandler.getLevel | test | private function getLevel(Throwable $exception): string
{
foreach ($this->resolvedOptions['levels'] as $class => $level) {
if ($exception instanceof $class) {
return $level;
}
}
if ($exception instanceof FatalErrorException) {
return self::$loggers[$exception->getSeverity()];
}
return LogLevel::ERROR;
} | php | {
"resource": ""
} |
q263008 | ErrorHandler.shouldntReport | test | private function shouldntReport(Throwable $exception): bool
{
foreach ($this->dontReport as $type) {
if ($exception instanceof $type) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q263009 | Dumper.addDumper | test | public function addDumper(DumperContract $dumper, string $extension): void
{
self::$supportedDumper[$extension] = $dumper;
} | php | {
"resource": ""
} |
q263010 | Dumper.dump | test | public function dump(array $data, string $format): string
{
$dumper = $this->getDumper($format);
return $dumper->dump($data);
} | php | {
"resource": ""
} |
q263011 | Dumper.getDumper | test | public function getDumper(string $type): DumperContract
{
if (isset(self::$supportedDumper[$type])) {
return new self::$supportedDumper[$type]();
}
if (isset(self::$supportedMimeTypes[$type])) {
$class = self::$supportedDumper[self::$supportedMimeTypes[$type]];
if (\is_object($class) && $class instanceof DumperContract) {
return $class;
}
return new $class();
}
throw new NotSupportedException(\sprintf('Given extension or mime type [%s] is not supported.', $type));
} | php | {
"resource": ""
} |
q263012 | LogTransport.getMimeEntityString | test | protected function getMimeEntityString(Swift_Message $entity): string
{
$string = (string) $entity->getHeaders() . \PHP_EOL . $entity->getBody();
foreach ($entity->getChildren() as $children) {
$string .= \PHP_EOL . \PHP_EOL . $this->getMimeEntityString($children);
}
return $string;
} | php | {
"resource": ""
} |
q263013 | HyphenatedInputResolver.getParameters | test | public function getParameters(
ReflectionFunctionAbstract $reflection,
array $providedParameters,
array $resolvedParameters
): array {
$parameters = [];
foreach ($reflection->getParameters() as $index => $parameter) {
$parameters[\mb_strtolower($parameter->name)] = $index;
}
foreach ($providedParameters as $name => $value) {
$normalizedName = \mb_strtolower(\str_replace('-', '', $name));
// Skip parameters that do not exist with the normalized name
if (! \array_key_exists($normalizedName, $parameters)) {
continue;
}
$normalizedParameterIndex = $parameters[$normalizedName];
// Skip parameters already resolved
if (\array_key_exists($normalizedParameterIndex, $resolvedParameters)) {
continue;
}
$resolvedParameters[$normalizedParameterIndex] = $value;
}
return $resolvedParameters;
} | php | {
"resource": ""
} |
q263014 | ScalarString.codePointToUtf8 | test | private static function codePointToUtf8(int $num): string
{
if ($num <= 0x7F) {
return \chr($num);
}
if ($num <= 0x7FF) {
return \chr(($num>>6) + 0xC0) . \chr(($num&0x3F) + 0x80);
}
if ($num <= 0xFFFF) {
return \chr(($num>>12) + 0xE0) . \chr((($num>>6)&0x3F) + 0x80) . \chr(($num&0x3F) + 0x80);
}
if ($num <= 0x1FFFFF) {
return \chr(($num>>18) + 0xF0) . \chr((($num>>12)&0x3F) + 0x80)
. \chr((($num>>6)&0x3F) + 0x80) . \chr(($num&0x3F) + 0x80);
}
throw new Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large.');
} | php | {
"resource": ""
} |
q263015 | QueueingBusServiceProvider.registerBusQueueingDispatcher | test | public static function registerBusQueueingDispatcher(ContainerInterface $container): QueueingDispatcherContract
{
return new QueueingDispatcher($container, static function ($connection = null) use ($container) {
return $container->get(FactoryContract::class)->connection($connection);
});
} | php | {
"resource": ""
} |
q263016 | RouteTreeOptimizer.optimize | test | public function optimize(array $routeTree): array
{
$segmentDepthNodeMap = $routeTree[1];
foreach ($segmentDepthNodeMap as $segmentDepth => $nodes) {
$segmentDepthNodeMap[$segmentDepth] = $this->optimizeNodes($nodes);
}
return [$routeTree[0], $segmentDepthNodeMap];
} | php | {
"resource": ""
} |
q263017 | RouteTreeOptimizer.extractCommonParentNode | test | private function extractCommonParentNode(RouteTreeNode $node1, RouteTreeNode $node2): ?RouteTreeNode
{
$matcherCompare = static function (SegmentMatcherContract $matcher, SegmentMatcherContract $matcher2) {
return \strcmp($matcher->getHash(), $matcher2->getHash());
};
$commonMatchers = \array_uintersect_assoc($node1->getMatchers(), $node2->getMatchers(), $matcherCompare);
if (\count($commonMatchers) === 0) {
return null;
}
$children = [];
$nodes = [$node1, $node2];
foreach ($nodes as $node) {
$specificMatchers = \array_udiff_assoc($node->getMatchers(), $commonMatchers, $matcherCompare);
$duplicateMatchers = \array_uintersect_assoc($node->getMatchers(), $commonMatchers, $matcherCompare);
foreach ($duplicateMatchers as $segmentDepth => $matcher) {
$commonMatchers[$segmentDepth]->mergeParameterKeys($matcher);
}
if (\count($specificMatchers) === 0 && $node->isParentNode()) {
foreach ($node->getContents()->getChildren() as $childNode) {
$children[] = $childNode;
}
} else {
$children[] = $node->update($specificMatchers, $node->getContents());
}
}
return new RouteTreeNode($commonMatchers, new ChildrenNodeCollection($children));
} | php | {
"resource": ""
} |
q263018 | TracedStatement.getSqlWithParams | test | public function getSqlWithParams($quotationChar = '<>'): string
{
if (($l = \mb_strlen($quotationChar)) > 1) {
$quoteLeft = \mb_substr($quotationChar, 0, $l / 2);
$quoteRight = \mb_substr($quotationChar, $l / 2);
} else {
$quoteLeft = $quoteRight = $quotationChar;
}
$sql = $this->sql;
foreach ($this->parameters as $k => $v) {
$v = "{$quoteLeft}{$v}{$quoteRight}";
if (! \is_numeric($k)) {
$sql = \str_replace($k, $v, $sql);
} else {
$p = \mb_strpos($sql, '?');
$sql = \mb_substr($sql, 0, $p) . $v . \mb_substr($sql, $p + 1);
}
}
return $sql;
} | php | {
"resource": ""
} |
q263019 | Util.tryFopen | test | public static function tryFopen(string $filename, string $mode)
{
$ex = null;
\set_error_handler(static function () use ($filename, $mode, &$ex): void {
$ex = new RuntimeException(\sprintf(
'Unable to open [%s] using mode %s: %s',
$filename,
$mode,
\func_get_args()[1]
));
});
$handle = \fopen($filename, $mode);
\restore_error_handler();
if ($ex instanceof Throwable) {
// @var $ex \RuntimeException
throw $ex;
}
return $handle;
} | php | {
"resource": ""
} |
q263020 | Util.createStreamFor | test | public static function createStreamFor($resource = '', array $options = []): StreamInterface
{
if (\is_scalar($resource)) {
$stream = self::tryFopen('php://temp', 'r+');
if ($resource !== '') {
\fwrite($stream, (string) $resource);
\fseek($stream, 0);
}
return new Stream($stream, $options);
}
$type = \gettype($resource);
if ($type === 'resource') {
return new Stream($resource, $options);
}
if ($type === 'object') {
if ($resource instanceof StreamInterface) {
return $resource;
}
if ($resource instanceof Iterator) {
return new PumpStream(static function () use ($resource) {
if (! $resource->valid()) {
return false;
}
$result = $resource->current();
$resource->next();
return $result;
}, $options);
}
if (\method_exists($resource, '__toString')) {
return self::createStreamFor($resource->__toString(), $options);
}
}
if ($type === 'NULL') {
return new Stream(self::tryFopen('php://temp', 'r+'), $options);
}
if (\is_callable($resource)) {
return new PumpStream($resource, $options);
}
throw new InvalidArgumentException('Invalid resource type: ' . \gettype($resource));
} | php | {
"resource": ""
} |
q263021 | Util.copyToString | test | public static function copyToString(StreamInterface $stream, int $maxLen = -1): string
{
$buffer = '';
if ($maxLen === -1) {
while (! $stream->eof()) {
$buf = $stream->read(1048576);
// Using a loose equality here to match on '' and false.
if (empty($buf)) {
break;
}
$buffer .= $buf;
}
return $buffer;
}
$len = 0;
while (! $stream->eof() && $len < $maxLen) {
$buf = $stream->read($maxLen - $len);
// Using a loose equality here to match on '' and false.
if (empty($buf)) {
break;
}
$buffer .= $buf;
$len = \strlen($buffer);
}
return $buffer;
} | php | {
"resource": ""
} |
q263022 | Util.copyToStream | test | public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void
{
if ($maxLen === -1) {
while (! $source->eof()) {
if (! (bool) $dest->write($source->read(1048576))) {
break;
}
}
return;
}
$bufferSize = 8192;
if ($maxLen === -1) {
while (! $source->eof()) {
if (! (bool) $dest->write($source->read($bufferSize))) {
break;
}
}
} else {
$remaining = $maxLen;
while ($remaining > 0 && ! $source->eof()) {
$buf = $source->read(\min($bufferSize, $remaining));
$len = \strlen($buf);
if (! $len) {
break;
}
$remaining -= $len;
$dest->write($buf);
}
}
} | php | {
"resource": ""
} |
q263023 | Util.readline | test | public static function readline(StreamInterface $stream, int $maxLength = null): string
{
$buffer = '';
$size = 0;
while (! $stream->eof()) {
$byte = $stream->read(1);
// Using a loose equality here to match on '' and false.
if ($byte === '' || $byte === false || $byte === null) {
return $buffer;
}
$buffer .= $byte;
// Break when a new line is found or the max length - 1 is reached
if ($byte === "\n" || ++$size === $maxLength - 1) {
break;
}
}
return $buffer;
} | php | {
"resource": ""
} |
q263024 | CookieJar.setDefaultPathAndDomain | test | public function setDefaultPathAndDomain(string $path, string $domain, bool $secure = false): self
{
[$this->path, $this->domain, $this->secure] = [$path, $domain, $secure];
return $this;
} | php | {
"resource": ""
} |
q263025 | CookieJar.getPathAndDomain | test | protected function getPathAndDomain(?string $path, ?string $domain, bool $secure = false): array
{
return [$path ?? $this->path, $domain ?? $this->domain, $secure ?? $this->secure];
} | php | {
"resource": ""
} |
q263026 | WhoopsPrettyDisplayer.getHandler | test | protected function getHandler(): Handler
{
$handler = new PrettyPageHandler();
$handler->handleUnconditionally(true);
foreach ($this->resolvedOptions['blacklist'] as $key => $secrets) {
foreach ($secrets as $secret) {
$handler->blacklist($key, $secret);
}
}
$handler->setApplicationPaths($this->resolvedOptions['application_paths']);
return $handler;
} | php | {
"resource": ""
} |
q263027 | Request.updateHostFromUri | test | private function updateHostFromUri(): void
{
$host = $this->uri->getHost();
if ($host === '') {
return;
}
if (($port = $this->uri->getPort()) !== null) {
$host .= ':' . $port;
}
$this->headerNames['host'] = 'Host';
// Remove an existing host header if present, regardless of current
// de-normalization of the header name.
// @see https://github.com/zendframework/zend-diactoros/issues/91
foreach (\array_keys($this->headers) as $oldHeader) {
if (\strtolower($oldHeader) === 'host') {
unset($this->headers[$oldHeader]);
}
}
// Ensure Host is the first header.
// See: http://tools.ietf.org/html/rfc7230#section-5.4
$this->headers = ['Host' => [$host]] + $this->headers;
} | php | {
"resource": ""
} |
q263028 | Request.filterMethod | test | private function filterMethod(?string $method): string
{
if ($method === null) {
return self::METHOD_GET;
}
if (! \preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method)) {
throw new InvalidArgumentException(\sprintf(
'Unsupported HTTP method [%s].',
$method
));
}
return $method;
} | php | {
"resource": ""
} |
q263029 | Request.createUri | test | private function createUri($uri): UriInterface
{
if ($uri instanceof UriInterface) {
return $uri;
}
if (\is_string($uri)) {
return Uri::createFromString($uri);
}
if ($uri === null) {
return Uri::createFromString();
}
throw new InvalidArgumentException(
'Invalid URI provided; must be null, a string or a [\Psr\Http\Message\UriInterface] instance.'
);
} | php | {
"resource": ""
} |
q263030 | FilesystemExtensionTrait.withoutExtension | test | public function withoutExtension(string $path, string $extension = null): string
{
$path = $this->getTransformedPath($path);
if ($extension !== null) {
// remove extension and trailing dot
return \rtrim(\basename($path, $extension), '.');
}
return \pathinfo($path, \PATHINFO_FILENAME);
} | php | {
"resource": ""
} |
q263031 | FilesystemExtensionTrait.changeExtension | test | public function changeExtension(string $path, string $extension): string
{
$path = $this->getTransformedPath($path);
$explode = \explode('.', $path);
$substrPath = \mb_substr($path, -1);
// No extension for paths
if ($substrPath === '/' || \is_dir($path)) {
return $path;
}
$actualExtension = null;
$extension = \ltrim($extension, '.');
if (\count($explode) >= 2 && ! \is_dir($path)) {
$actualExtension = \mb_strtolower($extension);
}
// No actual extension in path
if ($actualExtension === null) {
return $path . ($substrPath === '.' ? '' : '.') . $extension;
}
return \mb_substr($path, 0, -\mb_strlen($actualExtension)) . $extension;
} | php | {
"resource": ""
} |
q263032 | CacheServiceProvider.createCacheManager | test | public static function createCacheManager(ContainerInterface $container): CacheManagerContract
{
$cache = new CacheManager($container->get('config'));
$cache->setContainer($container);
return $cache;
} | php | {
"resource": ""
} |
q263033 | StaticalProxy.shouldReceive | test | public static function shouldReceive()
{
$name = static::getInstanceIdentifier();
if (static::isMock()) {
$mock = static::$resolvedInstance[$name];
} else {
$mock = static::createFreshMockInstance($name);
}
return $mock->shouldReceive(...\func_get_args());
} | php | {
"resource": ""
} |
q263034 | StaticalProxy.resolveStaticalProxyInstance | test | protected static function resolveStaticalProxyInstance($name): object
{
if (\is_object($name)) {
return $name;
}
if (isset(static::$resolvedInstance[$name])) {
return static::$resolvedInstance[$name];
}
return static::$resolvedInstance[$name] = static::$container->get($name);
} | php | {
"resource": ""
} |
q263035 | StaticalProxy.isMock | test | protected static function isMock(): bool
{
$name = static::getInstanceIdentifier();
return isset(static::$resolvedInstance[$name]) &&
static::$resolvedInstance[$name] instanceof MockInterface;
} | php | {
"resource": ""
} |
q263036 | Dispatcher.inflectSegment | test | protected function inflectSegment($command, int $segment): string
{
$className = \get_class($command);
// Get the given segment from a given class handler.
if (isset($this->mappings[$className])) {
return \explode('@', $this->mappings[$className])[$segment];
}
// Get the given segment from a given class handler using the custom mapper.
if (\is_callable($this->mapper)) {
return \explode('@', \call_user_func($this->mapper, [$command]))[$segment];
}
throw new InvalidArgumentException(\sprintf('No handler registered for command [%s].', $className));
} | php | {
"resource": ""
} |
q263037 | BinaryFileResponse.setFile | test | public function setFile(
$file,
string $contentDisposition = null,
bool $autoETag = false,
bool $autoLastModified = true
): ResponseInterface {
if (! $file instanceof File) {
if ($file instanceof SplFileInfo) {
$file = new File($file->getPathname());
} elseif (\is_string($file)) {
$file = new File($file);
} else {
throw new InvalidArgumentException(\sprintf(
'Invalid content [%s] provided to %s.',
(\is_object($file) ? \get_class($file) : \gettype($file)),
__CLASS__
));
}
}
if (! $file->isReadable()) {
throw new FileException('File must be readable.');
}
$this->file = $file;
if ($autoETag === true) {
$this->setAutoEtag();
}
if ($autoLastModified === true) {
$this->setAutoLastModified();
}
if ($contentDisposition) {
$this->headers['Content-Length'] = [$this->file->getSize()];
$this->headers['Content-Disposition'] = [
InteractsWithDisposition::makeDisposition(
$contentDisposition,
$this->file->getFilename(),
InteractsWithDisposition::encodedFallbackFilename($this->file->getFilename())
),
];
$this->headerNames['content-length'] = 'Content-Length';
$this->headerNames['content-disposition'] = 'Content-Disposition';
if (! $this->hasHeader('Content-Type')) {
$this->headers['Content-Type'] = [$this->file->getMimeType() ?? 'application/octet-stream'];
$this->headerNames['content-type'] = 'Content-Type';
}
}
return $this;
} | php | {
"resource": ""
} |
q263038 | BinaryFileResponse.setContentDisposition | test | public function setContentDisposition(
string $disposition,
string $filename = '',
string $filenameFallback = ''
): ResponseInterface {
if ($filenameFallback === '') {
$filenameFallback = InteractsWithDisposition::encodedFallbackFilename($filename);
}
return InteractsWithDisposition::appendDispositionHeader($this, $disposition, $filename, $filenameFallback);
} | php | {
"resource": ""
} |
q263039 | BinaryFileResponse.setAutoLastModified | test | protected function setAutoLastModified(): void
{
$date = DateTime::createFromFormat('U', (string) $this->file->getMTime());
$date = DateTimeImmutable::createFromMutable($date);
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$this->headers['Last-Modified'] = [$date->format('D, d M Y H:i:s') . ' GMT'];
$this->headerNames['last-modified'] = 'Last-Modified';
} | php | {
"resource": ""
} |
q263040 | Cookie.withValue | test | public function withValue(?string $value = null): Cookie
{
$this->validateValue($value);
$new = clone $this;
$new->value = $value;
return $new;
} | php | {
"resource": ""
} |
q263041 | TextDescriptor.describe | test | public function describe(OutputInterface $output, $object, array $options = []): void
{
/** @var Application $application */
$application = $object->getApplication();
$this->describeTitle($application, $output);
$describedNamespace = $options['namespace'] ?? null;
if ($describedNamespace !== null) {
$output->write(\sprintf(
"<comment>Available commands for the [%s] namespace</comment>\n\n",
$describedNamespace
));
}
$this->describeUsage($output);
$this->describeCommands($application, $object, $options);
} | php | {
"resource": ""
} |
q263042 | TextDescriptor.describeCommands | test | private function describeCommands(Application $application, AbstractCommand $command, array $options): void
{
$description = new ApplicationDescription(
$application,
$options['namespace'] ?? null,
$options['show-hidden'] ?? false
);
Table::setStyleDefinition('zero', self::getZeroBorderStyle());
$rows = [];
$namespaceSortedCommandInfos = $this->getNamespaceSortedCommandInfos(
$description->getCommands()
);
foreach ($namespaceSortedCommandInfos as $namespace => $infos) {
$stringCommands = '';
$stringDescriptions = '';
foreach ($infos as $info) {
$description = '';
if ($options['show-description'] ?? false) {
$description = $info['description'];
}
$stringCommands .= '<fg=green>' . $info['command'] . "</>\n";
$stringDescriptions .= $description . "\n";
}
$rows[] = [$namespace, $stringCommands, $stringDescriptions];
}
$command->table([], $rows, 'zero');
} | php | {
"resource": ""
} |
q263043 | TextDescriptor.getNamespaceSortedCommandInfos | test | private function getNamespaceSortedCommandInfos(array $commands): array
{
$namespaceSortedInfos = [];
$regex = '/^(.*)\:/';
$binary = Application::cerebroBinary();
/** @var AbstractCommand $command */
foreach ($commands as $name => $command) {
\preg_match($regex, $name, $matches, \PREG_OFFSET_CAPTURE);
$commandInfo = [
'command' => $binary . ' ' . $command->getSynopsis(),
'description' => $command->getDescription(),
];
if (\count($matches) === 0) {
$namespaceSortedInfos[$name][] = $commandInfo;
} else {
$namespaceSortedInfos[$matches[1][0]][] = $commandInfo;
}
}
return $namespaceSortedInfos;
} | php | {
"resource": ""
} |
q263044 | ViserioHttpDataCollector.createCookieTab | test | protected function createCookieTab(ServerRequestInterface $serverRequest, ResponseInterface $response): array
{
if (! (\class_exists(RequestCookies::class) && \class_exists(ResponseCookies::class))) {
return [];
}
$requestCookies = $responseCookies = [];
/** @var Cookie $cookie */
foreach (RequestCookies::fromRequest($serverRequest)->getAll() as $cookie) {
$requestCookies[$cookie->getName()] = $cookie->getValue();
}
/** @var CookieContract $cookie */
foreach (ResponseCookies::fromResponse($response)->getAll() as $cookie) {
$responseCookies[$cookie->getName()] = $cookie->getValue();
}
return [
'name' => 'Cookies',
'content' => $this->createTable(
$requestCookies,
[
'name' => 'Request Cookies',
'empty_text' => 'No request cookies',
]
) . $this->createTable(
$responseCookies,
[
'name' => 'Response Cookies',
'empty_text' => 'No response cookies',
]
),
];
} | php | {
"resource": ""
} |
q263045 | ViserioHttpDataCollector.prepareRequestAttributes | test | protected function prepareRequestAttributes(array $attributes): array
{
$preparedAttributes = [];
foreach ($attributes as $key => $value) {
if ($key === '_route') {
if (\is_object($value) && $value instanceof RouteContract) {
/** @var RouteContract $route */
$route = $value;
$value = [
'Uri' => $route->getUri(),
'Parameters' => $route->getParameters(),
];
}
$preparedAttributes[$key] = $value;
} elseif ($value instanceof StoreContract) {
$preparedAttributes[$key] = $value->getId();
} else {
$preparedAttributes[$key] = $value;
}
}
return $preparedAttributes;
} | php | {
"resource": ""
} |
q263046 | ViserioHttpDataCollector.prepareRequestHeaders | test | protected function prepareRequestHeaders(array $headers): array
{
$preparedHeaders = [];
foreach ($headers as $key => $value) {
if (\count((array) $value) === 1) {
$preparedHeaders[$key] = $value[0];
} else {
$preparedHeaders[$key] = $value;
}
}
return $preparedHeaders;
} | php | {
"resource": ""
} |
q263047 | ViserioHttpDataCollector.prepareServerParams | test | protected function prepareServerParams(array $params): array
{
$preparedParams = [];
foreach ($params as $key => $value) {
if (\preg_match('/(_KEY|_PASSWORD|_PW|_SECRET)/', $key)) {
$preparedParams[$key] = '******';
} else {
$preparedParams[$key] = $value;
}
}
return $preparedParams;
} | php | {
"resource": ""
} |
q263048 | ViserioHttpDataCollector.getParsedBody | test | private function getParsedBody(ServerRequestInterface $request): array
{
$parsedBody = $request->getParsedBody();
if (\is_object($parsedBody)) {
return (array) $parsedBody;
}
if ($parsedBody === null) {
return [];
}
return $parsedBody;
} | php | {
"resource": ""
} |
q263049 | IniDumper.export | test | private static function export($value): string
{
if (null === $value) {
return 'null';
}
if (\is_bool($value)) {
return $value ? 'true' : 'false';
}
if (\is_numeric($value)) {
return '"' . $value . '"';
}
return \sprintf('"%s"', $value);
} | php | {
"resource": ""
} |
q263050 | FilesystemManager.cryptedConnection | test | public function cryptedConnection(EncryptionKey $key, string $name = null): EncryptionWrapper
{
return new EncryptionWrapper($this->getConnection($name), $key);
} | php | {
"resource": ""
} |
q263051 | FilesystemManager.getCacheConfig | test | protected function getCacheConfig(string $name): array
{
$cache = $this->resolvedOptions['cached'];
if (! \is_array($config = ($cache[$name] ?? false)) && ! $config) {
throw new InvalidArgumentException(\sprintf('Cache [%s] not configured.', $name));
}
$config['name'] = $name;
return $config;
} | php | {
"resource": ""
} |
q263052 | FilesystemManager.adapt | test | protected function adapt(AdapterInterface $adapter, array $config): FilesystemContract
{
if (isset($config['cache']) && \is_array($config['cache'])) {
$cacheFactory = new CachedFactory($this, $this->getCacheManager());
$adapter = new CachedAdapter($adapter, $cacheFactory->getConnection($config));
unset($config['cache']);
}
return new FilesystemAdapter($adapter, $config);
} | php | {
"resource": ""
} |
q263053 | Parser.parse | test | public static function parse(string $route, array $conditions): array
{
if (\strlen($route) > 1 && $route[0] !== '/') {
throw new InvalidRoutePatternException(\sprintf(
'Invalid route pattern: non-root route must be prefixed with \'/\', \'%s\' given.',
$route
));
}
$segments = [];
$matches = [];
$names = [];
$patternSegments = \explode('/', $route);
\array_shift($patternSegments);
foreach ($patternSegments as $key => $patternSegment) {
if (self::matchRouteParameters($route, $patternSegment, $conditions, $matches, $names)) {
$segments[] = new ParameterMatcher(
$names,
self::generateRegex($matches, $conditions)
);
} else {
$segments[] = new StaticMatcher($patternSegment);
}
}
return $segments;
} | php | {
"resource": ""
} |
q263054 | Parser.generateRegex | test | private static function generateRegex(array $matches, array $parameterPatterns): string
{
$regex = '/^';
foreach ($matches as $match) {
[$type, $part] = $match;
if ($type === self::STATIC_PART) {
$regex .= \preg_quote($part, '/');
} else {
// Parameter, $part is the parameter name
$pattern = $parameterPatterns[$part] ?? Pattern::ANY;
$regex .= '(' . $pattern . ')';
}
}
return $regex . '$/';
} | php | {
"resource": ""
} |
q263055 | Invoker.getInvoker | test | private function getInvoker(): InvokerInterface
{
if ($this->invoker === null) {
$resolvers = \array_merge([
new AssociativeArrayResolver(),
new NumericArrayResolver(),
new TypeHintResolver(),
new DefaultValueResolver(),
], $this->resolvers);
if (($container = $this->container) !== null) {
if (isset($this->inject['type'])) {
$resolvers[] = new TypeHintContainerResolver($container);
}
if (isset($this->inject['parameter'])) {
$resolvers[] = new ParameterNameContainerResolver($container);
}
$this->invoker = new DiInvoker(new ResolverChain($resolvers), $container);
} else {
$this->invoker = new DiInvoker(new ResolverChain($resolvers));
}
}
return $this->invoker;
} | php | {
"resource": ""
} |
q263056 | ExistTrait.exists | test | protected function exists($object, bool $autoload = true): bool
{
return \class_exists($object, $autoload) ||
\interface_exists($object, $autoload) ||
\trait_exists($object, $autoload);
} | php | {
"resource": ""
} |
q263057 | XliffLintCommand.getTargetLanguageFromFile | test | private function getTargetLanguageFromFile(DOMDocument $xliffContents): ?string
{
foreach ($xliffContents->getElementsByTagName('file')[0]->attributes ?? [] as $attribute) {
if ($attribute->nodeName === 'target-language') {
return $attribute->nodeValue;
}
}
return null;
} | php | {
"resource": ""
} |
q263058 | WebServerServiceProvider.createVarDumpConnection | test | public static function createVarDumpConnection(ContainerInterface $container): Connection
{
$resolvedOptions = self::resolveOptions($container->get('config'));
$contextProviders = [];
if ($container->has(ServerRequestInterface::class) && $container->has(RequestContextProvider::class)) {
$contextProviders['request'] = $container->get(RequestContextProvider::class);
}
if ($container->has(SourceContextProvider::class)) {
$contextProviders['source'] = $container->get(SourceContextProvider::class);
}
return new Connection(
$resolvedOptions['debug_server']['host'],
$contextProviders
);
} | php | {
"resource": ""
} |
q263059 | WebServerServiceProvider.createDumpServer | test | public static function createDumpServer(ContainerInterface $container): DumpServer
{
$connection = $container->get(Connection::class);
// @codeCoverageIgnoreStart
VarDumper::setHandler(static function ($var) use ($connection): void {
$data = (new VarCloner())->cloneVar($var);
if ($connection->write($data)) {
(new CliDumper())->dump($data);
}
});
// @codeCoverageIgnoreEnd
$logger = null;
if ($container->has(LoggerInterface::class)) {
$logger = $container->get(LoggerInterface::class);
}
$resolvedOptions = self::resolveOptions($container->get('config'));
return new DumpServer(
$resolvedOptions['debug_server']['host'],
$logger
);
} | php | {
"resource": ""
} |
q263060 | FilesystemAdapter.has | test | public function has(string $path): bool
{
$has = $this->driver->has($path);
if ($has === null) {
return false;
}
if (\is_array($has)) {
return $has['path'] !== '';
}
return $has;
} | php | {
"resource": ""
} |
q263061 | FilesystemAdapter.getTransformedPath | test | protected function getTransformedPath(string $path): string
{
$prefix = '';
if (\method_exists($this->driver, 'getPathPrefix')) {
$prefix = $this->driver->getPathPrefix();
}
return $prefix . $path;
} | php | {
"resource": ""
} |
q263062 | FilesystemAdapter.getContents | test | private function getContents(string $directory, string $typ, bool $recursive = false): array
{
$contents = $this->driver->listContents($directory, $recursive);
return $this->filterContentsByType($contents, $typ);
} | php | {
"resource": ""
} |
q263063 | FilesystemAdapter.filterContentsByType | test | private function filterContentsByType(array $contents, string $type): array
{
$results = [];
foreach ($contents as $key => $value) {
if (isset($value['type']) && $value['type'] === $type) {
$results[$key] = $value['path'];
}
}
return $results;
} | php | {
"resource": ""
} |
q263064 | VerifyCsrfTokenMiddleware.tokensMatch | test | protected function tokensMatch(ServerRequestInterface $request): bool
{
$sessionToken = $request->getAttribute('session')->getToken();
$token = $request->getAttribute('_token') ?? $request->getHeaderLine('x-csrf-token');
$header = $request->getHeaderLine('x-xsrf-token');
if ($token === '' && $header !== '') {
try {
$key = KeyFactory::loadEncryptionKey($this->manager->getConfig()['key_path']);
$hiddenString = Crypto::decrypt($header, $key);
$token = $hiddenString->getString();
} catch (InvalidMessage $exception) {
$token = $header;
}
}
if (! \is_string($sessionToken) || ! \is_string($token)) {
return false;
}
return \hash_equals($sessionToken, $token);
} | php | {
"resource": ""
} |
q263065 | VerifyCsrfTokenMiddleware.addCookieToResponse | test | protected function addCookieToResponse(
ServerRequestInterface $request,
ResponseInterface $response
): ResponseInterface {
$uri = $request->getUri();
$setCookie = new SetCookie(
'XSRF-TOKEN',
$request->getAttribute('session')->getToken(),
$this->lifetime,
$this->cookieConfig['path'],
$this->cookieConfig['domain'] ?? $uri->getHost(),
$this->cookieConfig['secure'] ?? ($uri->getScheme() === 'https'),
false,
$this->cookieConfig['samesite']
);
return $response->withAddedHeader('set-cookie', (string) $setCookie);
} | php | {
"resource": ""
} |
q263066 | ViserioTranslationDataCollector.sanitizeCollectedMessages | test | protected function sanitizeCollectedMessages(array $messages): array
{
$result = [];
foreach ($messages as $key => $message) {
$messageId = $message['locale'] . '.' . $message['domain'] . '.' . $message['id'];
if (! isset($result[$messageId])) {
$message['count'] = 1;
$message['parameters'] = ! isset($message['parameters']) ? [$message['parameters']] : [];
$messages[$key]['translation'] = $message['translation'];
$result[$messageId] = $message;
} else {
if (! isset($message['parameters'])) {
$result[$messageId]['parameters'][] = $message['parameters'];
}
$result[$messageId]['count']++;
}
unset($messages[$key]);
}
return $result;
} | php | {
"resource": ""
} |
q263067 | ViserioTranslationDataCollector.computeCount | test | protected function computeCount(array $messages): array
{
$count = [
TranslatorContract::MESSAGE_DEFINED => 0,
TranslatorContract::MESSAGE_MISSING => 0,
TranslatorContract::MESSAGE_EQUALS_FALLBACK => 0,
];
foreach ($messages as $message) {
$count[$message['state']]++;
}
return $count;
} | php | {
"resource": ""
} |
q263068 | ViserioTranslationDataCollector.getSortedMessages | test | protected function getSortedMessages(array $messages): array
{
$sortedMessages = [
TranslatorContract::MESSAGE_MISSING => [],
TranslatorContract::MESSAGE_EQUALS_FALLBACK => [],
TranslatorContract::MESSAGE_DEFINED => [],
];
foreach ($messages as $key => $value) {
if ($value['state'] === TranslatorContract::MESSAGE_MISSING) {
$sortedMessages[TranslatorContract::MESSAGE_MISSING][$value['id']] = [
$value['locale'],
$value['domain'],
$value['count'],
$value['id'],
$value['translation'],
];
} elseif ($value['state'] === TranslatorContract::MESSAGE_EQUALS_FALLBACK) {
$sortedMessages[TranslatorContract::MESSAGE_EQUALS_FALLBACK][$value['id']] = [
$value['locale'],
$value['domain'],
$value['count'],
$value['id'],
$value['translation'],
];
} elseif ($value['state'] === TranslatorContract::MESSAGE_DEFINED) {
$sortedMessages[TranslatorContract::MESSAGE_DEFINED][$value['id']] = [
$value['locale'],
$value['domain'],
$value['count'],
$value['id'],
$value['translation'],
];
}
}
return $sortedMessages;
} | php | {
"resource": ""
} |
q263069 | AppendStream.addStream | test | public function addStream(StreamInterface $stream): void
{
if (! $stream->isReadable()) {
throw new InvalidArgumentException('Each stream must be readable.');
}
// The stream is only seekable if all streams are seekable
if (! $stream->isSeekable()) {
$this->seekable = false;
}
$this->streams[] = $stream;
} | php | {
"resource": ""
} |
q263070 | AppendStream.close | test | public function close(): void
{
$this->pos = $this->current = 0;
$this->seekable = true;
foreach ($this->streams as $stream) {
$stream->close();
}
$this->streams = [];
} | php | {
"resource": ""
} |
q263071 | Decoder.decode | test | public function decode()
{
$gif = new Decoded;
// read header
$gif->setHeader($this->getNextBytes(6));
// read logocal screen descriptor
$gif->setlogicalScreenDescriptor($this->getNextBytes(7));
// read global color table
if ($gif->hasGlobalColorTable()) {
$gif->setGlobalColorTable($this->getNextBytes(
$gif->countGlobalColors() * 3
));
}
// read body
while ( ! feof($this->handle)) {
switch ($this->getNextBytes(1)) {
case self::EXTENSION_BLOCK_MARKER:
$this->decodeExtension($gif);
break;
case self::IMAGE_SEPARATOR:
$this->decodeImageDescriptor($gif);
$this->decodeImageData($gif);
break;
case self::TRAILER_MARKER:
# code...
break 2;
default:
throw new \Intervention\Image\Exception\NotReadableException(
"Unable to decode GIF image."
);
break;
}
}
return $gif;
} | php | {
"resource": ""
} |
q263072 | Decoder.decodeExtension | test | private function decodeExtension(Decoded $gif)
{
switch ($this->getNextBytes(1)) {
case self::GRAPHICS_CONTROL_EXTENSION_MARKER:
$gif->addGraphicsControlExtension($this->getNextBytes(6));
break;
case self::APPLICATION_EXTENSION_MARKER:
$application_block_size = $this->getNextBytes(1);
$application_block_size = unpack('C', $application_block_size)[1];
$application_block = $this->getNextBytes($application_block_size);
// only save netscape application extension
if ($application_block == self::NETSCAPE_EXTENSION_MARKER) {
$data_block_size = $this->getNextBytes(1);
$data_block_size = unpack('C', $data_block_size)[1];
$data_block = $this->getNextBytes($data_block_size);
$extension = "\x0B";
$extension .= self::NETSCAPE_EXTENSION_MARKER;
$extension .= "\x03";
$extension .= $data_block;
$extension .= "\x00";
$gif->setNetscapeExtension($extension);
} elseif ($application_block == self::XMP_EXTENSION_MARKER) {
do {
// skip xmp data for now
$byte = $this->getNextBytes(1);
} while ($byte != "\x00");
} else {
$data_block_size = $this->getNextBytes(1);
$data_block_size = unpack('C', $data_block_size)[1];
$data_block = $this->getNextBytes($data_block_size);
}
// subblock
$this->getNextBytes(1);
break;
case self::PLAINTEXT_EXTENSION_MARKER:
$blocksize = $this->getNextBytes(1);
$blocksize = unpack('C', $blocksize)[1];
$gif->setPlaintextExtension($this->getNextBytes($blocksize));
$this->getNextBytes(1); // null byte
break;
case self::COMMENT_EXTENSION_MARKER:
$blocksize = $this->getNextBytes(1);
$blocksize = unpack('C', $blocksize);
$gif->setCommentExtension($this->getNextBytes($blocksize));
$this->getNextBytes(1); // null byte
break;
default:
# code...
break;
}
} | php | {
"resource": ""
} |
q263073 | Decoder.decodeImageDescriptor | test | private function decodeImageDescriptor(Decoded $gif)
{
$descriptor = $this->getNextBytes(9);
// determine if descriptor has local color table
$flag = substr($descriptor, 8, 1);
$flag = unpack('C', $flag)[1];
$flag = (bool) ($flag & bindec('10000000'));
if ($flag) {
// read local color table
$byte = substr($descriptor, 8, 1);
$byte = unpack('C', $byte)[1];
$size = (int) ($byte & bindec('00000111'));
$size = 3 * pow(2, $size + 1);
$gif->addLocalColorTable($this->getNextBytes($size));
} else {
$gif->addLocalColorTable(null);
}
// determine if image is marked as interlaced
$interlaced = substr($descriptor, 8, 1);
$interlaced = unpack('C', $interlaced)[1];
$interlaced = (bool) ($interlaced & bindec('01000000'));
$gif->addInterlaced($interlaced);
// decode image offsets
$left = substr($descriptor, 0, 2);
$left = unpack('C', $left)[1];
$top = substr($descriptor, 2, 2);
$top = unpack('C', $top)[1];
$gif->addOffset($left, $top);
// decode image dimensions
$width = substr($descriptor, 4, 2);
$width = unpack('v', $width)[1];
$height = substr($descriptor, 6, 2);
$height = unpack('v', $height)[1];
$gif->addSize($width, $height);
$gif->addImageDescriptors($descriptor);
} | php | {
"resource": ""
} |
q263074 | Decoder.decodeImageData | test | private function decodeImageData(Decoded $gif)
{
$data = '';
// LZW minimum code size
$data .= $this->getNextBytes(1);
do {
$byte = $this->getNextBytes(1);
if ($byte !== self::BLOCK_TERMINATOR) {
$size = unpack('C', $byte)[1];
$data .= $byte;
$data .= $this->getNextBytes($size);
} else {
$data .= self::BLOCK_TERMINATOR;
}
} while ($byte !== self::BLOCK_TERMINATOR);
$gif->addImageData($data);
} | php | {
"resource": ""
} |
q263075 | ServerPaginatedCollection.setOrderDir | test | public function setOrderDir($orderDir = CDRCollection::ORDER_ASC)
{
if ($orderDir != self::ORDER_ASC && $orderDir != self::ORDER_DESC) {
throw new CDRCollectionException("Unknown order direction");
}
$this->orderDir = $orderDir;
} | php | {
"resource": ""
} |
q263076 | ServerPaginatedCollection.getList | test | public function getList()
{
if (!$this->_loaded) {
$this->load();
$this->_loaded = true;
}
return $this->_list;
} | php | {
"resource": ""
} |
q263077 | ServerPaginatedCollection.load | test | public function load()
{
$response = $this->call($this->getMethod(), $this->getArgs());
$this->_list = array();
$key = $this->getResponseKey();
foreach ($response[$key] as $value) {
$this->appendToList($value);
}
$this->setLimit($response['pagination']->limit);
$this->setOffset($response['pagination']->offset);
$this->setTotal($response['pagination']->total);
} | php | {
"resource": ""
} |
q263078 | Country.setCitiesFromArray | test | protected function setCitiesFromArray($cities = array())
{
$this->_cities = array();
foreach ($cities as $city) {
$city = new City((array)$city);
$city->setCountry($this);
$this->_cities[$city->getCityId()] = $city;
}
} | php | {
"resource": ""
} |
q263079 | Country.setPSTNNetworksFromArray | test | protected function setPSTNNetworksFromArray($networks = array())
{
$this->_pstnNetworks = array();
foreach ($networks as $network) {
$network = new PSTNNetwork((array)$network);
$network->setCountry($this);
$this->_pstnNetworks[] = $network;
}
} | php | {
"resource": ""
} |
q263080 | Country.loadPSTNNetworks | test | public function loadPSTNNetworks($networkPrefix = NULL)
{
if (!$this->getCountryIso()) {
throw new CountryException("ISO code is undefined");
}
if (!$this->_loadedNetworks) {
$response = $this->call("getdidwwpstnrates", array(
"country_iso" => $this->getCountryIso(),
"pstn_prefix" => $networkPrefix
));
$country = reset($response);
$this->fromArray((array)$country);
$this->_loadedNetworks = true;
}
return $this;
} | php | {
"resource": ""
} |
q263081 | Country.loadCities | test | public function loadCities($prefix = NULL)
{
if (!$this->getCountryIso()) {
throw new CountryException("ISO code is undefined");
}
if (!$this->_loadedCities) {
$response = $this->call("getdidwwregions", array(
"country_iso" => $this->getCountryIso(),
"city_prefix" => $prefix
));
$country = reset($response);
$this->fromArray((array)$country);
$this->_loadedCities = true;
}
return $this;
} | php | {
"resource": ""
} |
q263082 | Country.getAll | test | public static function getAll($iso = NULL)
{
$countries = array();
$response = self::getClientInstance()->call("getdidwwcountries", array('country_iso' => $iso)
);
foreach ($response as $c) {
$country = new Country((array)$c);
$countries[$country->getCountryIso()] = $country;
}
return $countries;
} | php | {
"resource": ""
} |
q263083 | Country.getCity | test | public function getCity($id)
{
$this->loadCities();
if (isset($this->_cities[$id])) {
return $this->_cities[$id];
}
throw new CountryException("City not found");
} | php | {
"resource": ""
} |
q263084 | Request.pkcs5_pad | test | private function pkcs5_pad($text, $blocksize)
{
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
} | php | {
"resource": ""
} |
q263085 | PSTNNetwork.getAll | test | public static function getAll($lastRequestGmt = NULL)
{
$countries = array();
$response = self::getClientInstance()->call("getdidwwpstnrates",
array('last_request_gmt' => $lastRequestGmt)
);
foreach ($response as $countryWithNetworks) {
$countries[trim($countryWithNetworks->country_iso)] = new \Didww\API2\Country((array)$countryWithNetworks);
}
return $countries;
} | php | {
"resource": ""
} |
q263086 | PSTNNetwork.updateAll | test | public static function updateAll($countries = array())
{
$networks = array();
foreach ($countries as $country) {
if ($country instanceof \Didww\API2\Country) {
$networks = array_merge($networks, $country->getPSTNNetworks());
} else {
throw new PSTNNetworkException("Country expected but type " .
\Didww\Utils\Util::getType($country) .
" found");
}
}
self::updateNetworks($networks);
} | php | {
"resource": ""
} |
q263087 | PSTNNetwork.updateNetworks | test | public static function updateNetworks($networks = array())
{
$request = array();
foreach ($networks as $network) {
if ($network instanceof \Didww\API2\PSTNNetwork) {
$request[] = array(
"network_prefix" => trim($network->getNetworkPrefix()),
"sell_rate" => $network->getSellRate()
);
} else {
throw new PSTNNetworkException("PSTNNetwork expected but type " .
\Didww\Utils\Util::getType($network) .
" found");
}
}
self::updateNetworksFromArray($request);
} | php | {
"resource": ""
} |
q263088 | Mapping.create | test | public static function create($params = array())
{
if (isset($params['type'])) {
$className = "Didww\API2\Mapping\\" . $params['type'];
$mapping = new $className();
unset($params['type']);
} else {
$mapping = new Mapping();
}
$mapping->fromArray($params);
return $mapping;
} | php | {
"resource": ""
} |
q263089 | Frame.decodeDelay | test | public function decodeDelay()
{
if ($this->graphicsControlExtension) {
$byte = substr($this->graphicsControlExtension, 2, 2);
return (int) unpack('v', $byte)[1];
}
return false;
} | php | {
"resource": ""
} |
q263090 | Frame.hasTransparentColor | test | public function hasTransparentColor()
{
if ($this->graphicsControlExtension) {
$byte = substr($this->graphicsControlExtension, 1, 1);
$byte = unpack('C', $byte)[1];
$bit = $byte & bindec('00000001');
return (bool) $bit;
}
return false;
} | php | {
"resource": ""
} |
q263091 | Frame.decodeDisposalMethod | test | public function decodeDisposalMethod()
{
if ($this->graphicsControlExtension) {
$byte = substr($this->graphicsControlExtension, 1, 1);
$byte = unpack('C', $byte)[1];
$method = $byte >> 2 & bindec('00000111');
return $method;
}
return 0;
} | php | {
"resource": ""
} |
q263092 | Frame.getSize | test | public function getSize()
{
$size = new \StdClass;
$size->width = $this->decodeWidth();
$size->height = $this->decodeHeight();
return $size;
} | php | {
"resource": ""
} |
q263093 | Frame.getOffset | test | public function getOffset()
{
$offset = new \StdClass;
$offset->left = $this->decodeOffsetLeft();
$offset->top = $this->decodeOffsetTop();
return $offset;
} | php | {
"resource": ""
} |
q263094 | Frame.setOffset | test | public function setOffset($left, $top)
{
$offset = new \StdClass;
$offset->left = $left;
$offset->top = $top;
$this->offset = $offset;
return $this;
} | php | {
"resource": ""
} |
q263095 | Order.getCountry | test | public function getCountry()
{
if (!($this->_country instanceof Country)) {
$this->_country = new Country();
$this->_country->setCountryIso($this->getCountryIso());
}
return $this->_country;
} | php | {
"resource": ""
} |
q263096 | Order.toArray | test | public function toArray($options = array())
{
$includeNumber = true;
if (isset($options['includeNumber'])) {
$includeNumber = (bool)$options['includeNumber'];
unset($options['includeNumber']);
}
return array_merge(parent::toArray($options), $includeNumber ? $this->_ensureNumber()->toArray() : array());
} | php | {
"resource": ""
} |
q263097 | Order.fromFlatList | test | public function fromFlatList($array)
{
//try to load order properties
$assignType = $this->getAssignType();
$this->setAssignType(\Didww\API2\Object::ASSIGN_IGNORE);
$array = parent::fromArray($array);
$this->setAssignType($assignType);
//try to load number properties
$number = $this->_ensureNumber();
$assignType = $number->getAssignType();
$number->setAssignType(\Didww\API2\Object::ASSIGN_IGNORE);
$array = $number->fromArray($array);
$number->setAssignType($assignType);
//finally create mapping object
$mapping = Mapping::create($array);
$this->setMapData($mapping);
} | php | {
"resource": ""
} |
q263098 | Order.fromArray | test | public function fromArray($array)
{
if (!empty($array['number'])) {
$this->_ensureNumber()->fromArray($array['number']);
unset($array['number']);
}
if (!empty($array['map_data'])) {
$this->setMapData(Mapping::create($array['map_data']));
unset($array['map_data']);
}
parent::fromArray($array);
} | php | {
"resource": ""
} |
q263099 | Order.createNumber | test | function createNumber()
{
if (!($this->getNumber() instanceof DIDNumber) || !$this->getNumber()->getDIDNumber()) {
$tmpHash = false;
if (!$this->uniqHash) {
$tmpHash = true;
$this->uniqHash = $this->generateUniqueHash();
}
$this->_number = DIDNumber::create($this);
if ($tmpHash) {
$this->uniqHash = NULL;
}
}
return $this;
} | 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.