_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q261200
Mondator.generateContainers
test
public function generateContainers() { $containers = array(); $containers['_global'] = new Container(); // global extensions $globalExtensions = $this->getExtensions(); // configClasses $configClasses = new \ArrayObject(); foreach ($this->getConfigClasses() ...
php
{ "resource": "" }
q261201
Mondator.dumpContainers
test
public function dumpContainers(array $containers) { // directories foreach ($containers as $container) { foreach ($container->getDefinitions() as $name => $definition) { $output = $definition->getOutput(); $dir = $output->getDir(); if (...
php
{ "resource": "" }
q261202
BoolSpec.it_should_return_inner_value
test
function it_should_return_inner_value() { $this->value()->shouldBeBool(); $this->value()->shouldBeEqualTo($this->init);
php
{ "resource": "" }
q261203
Client.setAddress
test
public function setAddress($address) { $this->address = \is_string($address) ? \explode(',',
php
{ "resource": "" }
q261204
Client.notice
test
public function notice($method, array $params = [], array $headers = []) { $request = new JsonRequest($method, $params);
php
{ "resource": "" }
q261205
Client.call
test
public function call($method, array $params = [], array $headers = []) { $request = new JsonRequest($method, $params, \uniqid(\gethostname().'.', true)); $request->headers()->add($headers); try { return $this->execute($request);
php
{ "resource": "" }
q261206
Client.createResponseFromException
test
protected function createResponseFromException(\Exception $e, JsonRequest $request) { $response = new JsonResponse(); $response->setId($request->getId());
php
{ "resource": "" }
q261207
Client.parserHttp
test
protected function parserHttp($http) { $response = []; $json = \json_decode($http, true); if (JSON_ERROR_NONE !== \json_last_error() || empty($http)) { throw new Exceptions\InvalidResponseException('Invalid response from RPC server, must be valid json.'); } /**...
php
{ "resource": "" }
q261208
Performer.requestForActionPermission
test
public function requestForActionPermission($dontWait = null) { $sendSuccess = null; if (!$this->requestSocket) { $this->requestSocket = $this->context->getSocket(\ZMQ::SOCKET_REQ); $this->requestSocket->connect($this->getSocketsParams()->getRequestPulsarRsSocketAddress()); ...
php
{ "resource": "" }
q261209
Performer.waitAllowingSubscriptionMessage
test
public function waitAllowingSubscriptionMessage() { if (!$this->subscriberSocket) { $this->subscriberSocket = $this->context->getSocket(\ZMQ::SOCKET_SUB); $this->subscriberSocket->connect($this->getSocketsParams()->getPublisherPulsarSocketAddress()); } $this->subscri...
php
{ "resource": "" }
q261210
Performer.pushActionResultInfo
test
public function pushActionResultInfo(ActionResultingPushDto $resultingPushDto) { $this->subscriberSocket->setSockOpt(\ZMQ::SOCKOPT_UNSUBSCRIBE, ""); $this->performerEarlyTerminated->setStandOnSubscription(false);
php
{ "resource": "" }
q261211
BaseSecurePresenter.formatLayoutTemplateFiles
test
public function formatLayoutTemplateFiles() { $list = parent::formatLayoutTemplateFiles(); $layout = $this->layout ? $this->layout : 'layout';
php
{ "resource": "" }
q261212
ComplexType.toFile
test
public function toFile($file, $jsonOptions = 0) { if (is_dir(pathinfo($file, PATHINFO_DIRNAME))) {
php
{ "resource": "" }
q261213
Str.dashed
test
public static function dashed($value) { if (isset(static::$dashedCache[$value])) {
php
{ "resource": "" }
q261214
SliceableTrait.getSlice
test
protected function getSlice($start, $stop, $step) { $length = $this->length(); $step = (isset($step)) ? $step : 1; if ($step === 0) { throw new InvalidArgumentException('Slice step cannot be 0'); } if (isset($start)) { $start = $this-...
php
{ "resource": "" }
q261215
SliceableTrait.getIndices
test
protected function getIndices($start, $stop, $step) { $indices = []; if ($step > 0) { for ($i = $start; $i < $stop; $i += $step) { $indices[] = $i; } } else {
php
{ "resource": "" }
q261216
Channel.getOption
test
public function getOption($value) { if(is_array($value)) { return $this->_getOptionFromArray($value); } elseif(preg_match($this->shortHandRegex, strtoupper($value))) { return '-channel ' . $value . ' '; } else { $msg = 'Invalid argument $value "' . $value . '", allowed values are ' . implode('...
php
{ "resource": "" }
q261217
Channel._validateValuesArrayArgument
test
private function _validateValuesArrayArgument(array $values) { foreach($values as $value) { if(!in_array($value, $this->allowedOptions)) { $msg = 'Invalid element in $value array: "' . $value . '", allowed values: ' . implode(', ',
php
{ "resource": "" }
q261218
Command._createOption
test
protected function _createOption($option, $value) { if(!class_exists($option)) { throw new InvalidOptionValueException('Option class "' . $option . '" not found.'); } $class = new $option();
php
{ "resource": "" }
q261219
Pulsar.declareReplyToReplyStackMessaging
test
protected function declareReplyToReplyStackMessaging() { $this->replyToReplyStack->on(EventsConstants::MESSAGE, function ($requestDto) { if ($this->getRequestForStartFromReplyStack === false) { $this->getRequestForStartFromReplyStack = true; $startReplyToReplyS...
php
{ "resource": "" }
q261220
Object.get
test
public function get($property, $default = null) { $property = $this->getStringable($property);
php
{ "resource": "" }
q261221
ContainerSpec.getMatchers
test
public function getMatchers() { return array( 'beInRange' => function($key, $match) { return in_array($key, $match); }, 'beArrayAndExactLengthOf' => function($array, $count)
php
{ "resource": "" }
q261222
ImageMagick.compareImages
test
public function compareImages($expectedImage, $compareImage, $resultImageName, $resultImageDirectory) { $time = date('Ymd-His'); $diffResult = $this->createDiffGifOnDifferences($expectedImage, $compareImage, $resultImageName . 'Diff' . $time, $resultImageDir...
php
{ "resource": "" }
q261223
ImageMagick.createDiffGifOnDifferences
test
public function createDiffGifOnDifferences($expectedImage, $compareImage, $resultImageName, $resultImageDirectory
php
{ "resource": "" }
q261224
ImageMagick.createComparisonImageOnDifferences
test
public function createComparisonImageOnDifferences($actualImage, $compareImage, $resultImageName,
php
{ "resource": "" }
q261225
Compare.same
test
public function same($expectedImage, $compareImage) { $metric = $this->_createOption(Metric::class, 'AE'); $cmd = 'compare ' . $metric . $expectedImage . ' ' . $compareImage . $this->redirectDefaultErrorResponse; return (int)`$cmd` === 0; } /** * Creates a comparison image. * * @param string $comp...
php
{ "resource": "" }
q261226
Router.post
test
public function post($route, $callback) {
php
{ "resource": "" }
q261227
Router.route
test
public function route(Route $route, $http_method = self::METHOD_GET) { // Is this a valid HTTP method? if (!in_array($http_method, array( self::METHOD_HEAD, self::METHOD_GET, self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, ...
php
{ "resource": "" }
q261228
Router.match
test
public function match($url, $http_method = self::METHOD_GET) { // Make sure there is a trailing slash $url = rtrim($url, '/') . '/'; foreach ($this->routes[$http_method] as $route) {
php
{ "resource": "" }
q261229
Router.run
test
public function run() { // If no routes have been added, then throw an exception try { if (empty($this->routes)) { throw new \RuntimeException('No routes exist in the routing table. Add some'); } } catch (\Exception $e) { $this->err...
php
{ "resource": "" }
q261230
Router.redirect
test
public function redirect($url) { // If no URL is given, throw exception try { if (empty($url)) { throw new \InvalidArgumentException('No URL given'); } } catch (\Exception $e) {
php
{ "resource": "" }
q261231
Router.parse_parameters
test
protected function parse_parameters(Route $route) { // Get all parameter matches from URL for this route $request_url = rtrim($this->request->getPathInfo(), '/') . '/'; preg_match($route->pattern(), "{$request_url}", $matches); $params = array(); // Retrieve any matches ...
php
{ "resource": "" }
q261232
ListRoute.date
test
protected function date($file) { $file_contents = $this->sonic->app['filesystem']->parse($file['path']); if (isset($file_contents['meta']['date']) === FALSE) {
php
{ "resource": "" }
q261233
MagicPresenter.handleSaveImage
test
public function handleSaveImage() { if ($this->mainManager instanceof MagicManager && $this->mainManager->isGallery() ) { $folder = $this->mainManager->getGalleryFolder(); } else { $this->error(); } if ($folder == '') { $folder = 'misc'; } $file = $this->httpRequest->getFile('Filedata'); ...
php
{ "resource": "" }
q261234
HttpRequest.get
test
public function get($strPath, array $arrOptions = []) { $request = wp_remote_get($this->build_uri($strPath), array_merge( self::DEFAULT_OPTIONS, $arrOptions, [
php
{ "resource": "" }
q261235
HttpRequest.post
test
public function post($strPath, array $arrOptions = []) { $request = wp_remote_post($this->build_uri($strPath), array_merge( self::DEFAULT_OPTIONS, $arrOptions, [
php
{ "resource": "" }
q261236
HttpRequest.set_auth
test
public function set_auth() { $date = date("Y-m-d\TH:i:s.000O"); $this->arrHeaders['X-cXense-Authentication'] = sprintf( 'username=%s date=%s hmac-sha256-hex=%s',
php
{ "resource": "" }
q261237
Helper.config
test
public function config($option) { return isset($this->app['settings'][$option]) ===
php
{ "resource": "" }
q261238
Helper.validate_config
test
public function validate_config($config) { $message = ''; while ($message === '') { if (!is_dir($this->app['ROOT_DIR'] . $config['sonic.content_dir'])) { $message = 'Content directory does not exist'; break; } if (!is_dir($this->a...
php
{ "resource": "" }
q261239
Helper.get_excerpt
test
public static function get_excerpt($text, $br_limit = 3) { if (substr_count($text, PHP_EOL) > $br_limit) { $excerpt = explode(PHP_EOL, $text, ++$br_limit);
php
{ "resource": "" }
q261240
Helper.handle_errors
test
public static function handle_errors($err_no, $err_str = '', $err_file = '', $err_line = '') { if (!($err_no & error_reporting())) { return; }
php
{ "resource": "" }
q261241
Helper.dot_extensions
test
private function dot_extensions() { $extensions = $this->app['settings']['sonic.content_ext']; foreach ($extensions as $extension) {
php
{ "resource": "" }
q261242
WidgetDocumentQuery.validateWidgetId
test
private function validateWidgetId(?string $widgetId) { if (!isset($widgetId) && current_user_can('administrator')) {
php
{ "resource": "" }
q261243
WidgetDocumentQuery.setCxenseUserId
test
public function setCxenseUserId() { if (!isset($_COOKIE['cX_P'])) { $this->cxenseUserId = '';
php
{ "resource": "" }
q261244
WidgetDocumentQuery.get
test
public function get() { $result = $this->getDocuments(); $objDocuments = isset($result->items) ? $result->items : []; return [
php
{ "resource": "" }
q261245
String.append
test
public function append($string, $delimiter = '') { if ($this->isValidStringAndDelimiter($string, $delimiter)) {
php
{ "resource": "" }
q261246
String.prepend
test
public function prepend($string, $delimiter = '') { if ($this->isValidStringAndDelimiter($string, $delimiter)) {
php
{ "resource": "" }
q261247
String.is
test
public function is($pattern) { return
php
{ "resource": "" }
q261248
String.limitWords
test
public function limitWords($limit, $end = '...') { return new static(Str::words($this->string,
php
{ "resource": "" }
q261249
String.uuid
test
public function uuid() { return new static(sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0,
php
{ "resource": "" }
q261250
String.join
test
public function join($glue, $array) { if ($this->isArrayable($array)) { $this->string = implode($this->retrieveValue($glue), $this->getArrayable($array));
php
{ "resource": "" }
q261251
String.toEntities
test
public function toEntities($flags = ENT_QUOTES, $encoding = 'UTF-8') {
php
{ "resource": "" }
q261252
String.cut
test
public function cut($offset, $length = null, $encoding = 'UTF-8') { return new static( mb_substr( $this->string, $this->getIntegerable($offset),
php
{ "resource": "" }
q261253
String.limit
test
public function limit($limit = 100, $end = '...') { return new static(
php
{ "resource": "" }
q261254
String.limitSafe
test
public function limitSafe($limit = 100, $end = '...') { return new static(
php
{ "resource": "" }
q261255
String.toVars
test
public function toVars() { $vars = []; return mb_parse_str($this->string, $vars) && !
php
{ "resource": "" }
q261256
String.encrypt
test
public function encrypt($key, $expires) { $payload = [ 'exp' => $this->getIntegerable($expires), 'string' => $this->string
php
{ "resource": "" }
q261257
String.fromEncrypted
test
public function fromEncrypted($encrypted, $key) { $encrypted = $this->retrieveValue($encrypted); $key = $this->retrieveValue($key); if ($this->isEncryptedString($encrypted, $key)) { $data = JWT::decode($encrypted, $key);
php
{ "resource": "" }
q261258
String.toContainer
test
public function toContainer() { $value = $this->value(); if ( ! $this->isFile() || ! $this->isJson() || ! $this->isSerialized()) {
php
{ "resource": "" }
q261259
Api.generateParserFromGrammar
test
static function generateParserFromGrammar( string $grammarFilePath, string $parserName="MyParser", string $namespace="", Output $output=null, string $pathToHeaderComment="") { $parser = new MetaGrammarParser(); $ast = !empty($grammarFilePath) ?
php
{ "resource": "" }
q261260
DocumentSearch.set_settings
test
public function set_settings() { if ($strPrefix = WpCxense::instance()->settings->getOrganisationPrefix()) { $this->arrFields['organisation'] = array_map(function ($strValue) use ($strPrefix) {
php
{ "resource": "" }
q261261
DocumentSearch.get_documents
test
public function get_documents() { $this->validate_query_key(); $objDocuments = $this ->set_per_page() ->set_page() ->set_facets() ->set_filter()
php
{ "resource": "" }
q261262
DocumentSearch.set_per_page
test
private function set_per_page($intCount = 10) { $this->arrPayload['count'] = $intCount; if (isset($this->arrSearch['count'])) {
php
{ "resource": "" }
q261263
DocumentSearch.set_page
test
private function set_page($intPage = 1) { if (!isset($this->arrPayload['count'])) { throw new DocumentSearchMissingCount('\DocumentSearch::setPerPage() is required before \DocumentSearch::setPage()'); } // get the page if (isset($this->arrSearch['page'])) {
php
{ "resource": "" }
q261264
RetrievableTrait.getNumberable
test
public function getNumberable($value, $default = null) { switch(true) { case is_int($value): case is_float($value): return $value; case is_numeric($value) && strpos($value, '.'): return (float) $value; case is_numeric($v...
php
{ "resource": "" }
q261265
RetrievableTrait.getSearchable
test
public function getSearchable($value, $default = []) { if ($this->isArrayable($value)) { return $this->getArrayable($value, $default); } elseif ($this->isStringable($value)) { return
php
{ "resource": "" }
q261266
RetrievableTrait.boolFromString
test
protected function boolFromString($value) { $grammar = $this->getGrammar(); $value = $this->getStringable($value);
php
{ "resource": "" }
q261267
RetrievableTrait.getGrammar
test
protected function getGrammar() { return [ 'true' => true, 'false' => false, 'on' => true, 'off' => false, 'yes' => true, 'no' => false,
php
{ "resource": "" }
q261268
Convert.createGifCommand
test
public function createGifCommand(array $sourcesImages, $resultImageName, $resultDirectory, $delay = 50, $loop = 0) {
php
{ "resource": "" }
q261269
Convert.createGifCommandCmd
test
public function createGifCommandCmd(array $sourcesImages, $resultImageName, $resultDirectory, $delay = 50, $loop = 0)
php
{ "resource": "" }
q261270
TokenStream.lookupMany
test
public function lookupMany($n = 1) { if ($n > $this->bufSize) { $this->bufSize = $n; } $this->fillBuffer();
php
{ "resource": "" }
q261271
Number.format
test
public function format($decimals = 2, $decimalDelimiter = '.', $thousandDelimiter = ' ') { return new String( number_format( (float) $this->value, $this->getIntegerable($decimals),
php
{ "resource": "" }
q261272
Definition.hasPropertyByName
test
public function hasPropertyByName($name) { foreach ($this->properties as $property) {
php
{ "resource": "" }
q261273
Definition.getPropertyByName
test
public function getPropertyByName($name) { foreach ($this->properties as $property) { if ($property->getName() == $name) { return $property; }
php
{ "resource": "" }
q261274
Definition.removePropertyByName
test
public function removePropertyByName($name) { foreach ($this->properties as $key => $property) { if ($property->getName() == $name) { unset($this->properties[$key]);
php
{ "resource": "" }
q261275
Definition.hasMethodByName
test
public function hasMethodByName($name) { foreach ($this->methods as $method) {
php
{ "resource": "" }
q261276
Definition.getMethodByName
test
public function getMethodByName($name) { foreach ($this->methods as $method) { if ($method->getName() == $name) { return $method; }
php
{ "resource": "" }
q261277
Definition.removeMethodByName
test
public function removeMethodByName($name) { foreach ($this->methods as $key => $method) { if ($method->getName() == $name) { unset($this->methods[$key]); return;
php
{ "resource": "" }
q261278
Markdown.parse_meta
test
protected function parse_meta($file) { // Grab meta section between '/* ... */' in the content file preg_match_all('#/\*(.*?)\*/#s', $file, $meta); // Retrieve individual meta fields preg_match_all('#^[\t]?(\w*):(.*)$#mi', $meta[1][0], $match);
php
{ "resource": "" }
q261279
Sonic.run_hooks
test
public function run_hooks($hook_id, $args = array()) { // If plugins are disabled, do not run if ($this->app['settings']['sonic.plugins_enabled'] === FALSE) { return FALSE; } // Run hooks associated with that event foreach ($this->app['plugins'] as
php
{ "resource": "" }
q261280
Sonic.load_plugins
test
protected function load_plugins() { if ($this->app['settings']['sonic.plugins_enabled'] === TRUE) { // Load plugins from 'plugins' folder $file_list = $this->app['filesystem']->listContents($this->app['settings']['sonic.plugins_dir']); $plugin_files = array_filter($f...
php
{ "resource": "" }
q261281
Sonic.setup_router
test
protected function setup_router() { // Only because you can't use $this->app in the callback $app = $this->app; $file_list = $app['filesystem']->listContents($app['settings']['sonic.content_dir'], true); $files = array_filter($file_list, function ($file) { retu...
php
{ "resource": "" }
q261282
Container.get
test
public function get($key, $default = null) { return Arr::get($this->items,
php
{ "resource": "" }
q261283
Container.set
test
public function set($key, $value) { Arr::set($this->items,
php
{ "resource": "" }
q261284
Container.pushToKey
test
public function pushToKey($key, $value) { if ( ! $this->has($key)) { $this->set($key, []); } $keyValue = $this->get($key); if ($keyValue instanceof static) { $keyValue->push($value); } elseif (is_array($keyValue)) { ...
php
{ "resource": "" }
q261285
Container.search
test
public function search($value, $strict = false) { return
php
{ "resource": "" }
q261286
Container.keysByField
test
public function keysByField($keyBy) { $byField = []; $keyBy = $this->getStringable($keyBy);
php
{ "resource": "" }
q261287
Container.unique
test
public function unique($recursive = false) { if ($this->getBoolable($recursive)) { return new
php
{ "resource": "" }
q261288
Container.numericKeys
test
public function numericKeys() { $keys = new static; foreach ($this->items as $key => $value) {
php
{ "resource": "" }
q261289
Container.join
test
public function join($glue = '') { foreach ($copy = Arr::flatten($this->items) as $key => $object)
php
{ "resource": "" }
q261290
Container.joinByKey
test
public function joinByKey($key, $glue = null) {
php
{ "resource": "" }
q261291
Container.lists
test
public function lists($valueByKey, $key = null) { return new static(Arr::pluck($this->items,
php
{ "resource": "" }
q261292
Container.chunk
test
public function chunk($size = 2, $preserveKeys = false) { $size = $this->getIntegerable($size); if ( ! is_integer($size) || $size > $this->length()) { throw new BadLengthException('Chunk size is larger than container length'); } $chunks = new static;
php
{ "resource": "" }
q261293
Container.filter
test
public function filter(callable $function, $recursive = false) { if ( ! $this->getBoolable($recursive))
php
{ "resource": "" }
q261294
Container.walk
test
public function walk(callable $callback, $recursive = false, $userdata = null) { $function = $this->getBoolable($recursive) ? 'array_walk_recursive' : 'array_walk';
php
{ "resource": "" }
q261295
Container.merge
test
public function merge($items) { if ( ! $this->isArrayable($items)) { throw new BadMethodCallException('Argument 1
php
{ "resource": "" }
q261296
Container.mergeWithKey
test
public function mergeWithKey($items, $key, $default = null) { $key = $this->getKey($key); if ( ! $this->has($key)) throw new InvalidArgumentException('Key: '.$key.' not exists'); $get = $this->get($key, $default);
php
{ "resource": "" }
q261297
Container.increase
test
public function increase($increaseSize = 1, $value = null) { $this->items = array_pad($this->items, $this->length() +
php
{ "resource": "" }
q261298
Container.randomKey
test
public function randomKey($quantity = 1) { $quantity = $this->getIntegerable($quantity); if ($this->isNotEmpty() && $this->length() >= $quantity && $quantity > 0) { $random = array_rand($this->items, $quantity); return is_array($random) ? new static($random) :
php
{ "resource": "" }
q261299
Container.random
test
public function random($quantity = 1) { $quantity = $this->getIntegerable($quantity); $result = new static;
php
{ "resource": "" }