_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.
... | 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 except... | 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)) {
... | 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 = ne... | 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 $transforme... | 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:... | 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]];
... | 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);
}
re... | 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)]... | 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) . \... | 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());
};
$commonMat... | 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... | 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,
... | 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);... | 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.
... | 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;
}
}
... | 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 ==... | 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);
... | 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 exis... | 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].',
... | 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();
}
thro... | 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(... | 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)) {
r... | 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_ar... | 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] = stati... | 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];
}
/... | 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($fil... | php | {
"resource": ""
} |
q263038 | BinaryFileResponse.setContentDisposition | test | public function setContentDisposition(
string $disposition,
string $filename = '',
string $filenameFallback = ''
): ResponseInterface {
if ($filenameFallback === '') {
$filenameFallback = InteractsWithDisposition::encodedFallbackFilename($filename);
}
... | 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... | 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 ($des... | 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::setStyleDefini... | 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) {
... | 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... | 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 $r... | 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;
... | 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[$k... | 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(... | 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'] =... | 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->getConnect... | 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
... | 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 {
... | 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(),
... | 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;
}
}
... | 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)) {
... | 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);
... | 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');
... | 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->... | 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['co... | 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) {... | php | {
"resource": ""
} |
q263068 | ViserioTranslationDataCollector.getSortedMessages | test | protected function getSortedMessages(array $messages): array
{
$sortedMessages = [
TranslatorContract::MESSAGE_MISSING => [],
TranslatorContract::MESSAGE_EQUALS_FALLBACK => [],
TranslatorContract::MESSAGE_DEFINED => [],
];
foreach ($messag... | 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->s... | 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()) {
... | 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:
... | 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) {
... | 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];
... | 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']... | 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->... | 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(),
... | 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->getCountryIs... | 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($cou... | 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... | 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()),
... | 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->... | 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 ? ... | 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 propertie... | 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']));
unse... | 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... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.