_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q27200
AddressBookHome.getChildren
train
public function getChildren() { $addressbooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri); $objs = []; foreach ($addressbooks as $addressbook) { $objs[] = new AddressBook($this->carddavBackend, $addressbook); } return $objs; }
php
{ "resource": "" }
q27201
Plugin.httpGet
train
public function httpGet(RequestInterface $request, ResponseInterface $response) { $path = $request->getPath(); try { $node = $this->server->tree->getNodeForPath($path); } catch (DAV\Exception\NotFound $e) { return; } if (!$node instanceof INode) { ...
php
{ "resource": "" }
q27202
Plugin.propFindEarly
train
public function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) { $ns = '{'.self::NS_CARDDAV.'}'; if ($node instanceof IAddressBook) { $propFind->handle($ns.'max-resource-size', $this->maxResourceSize); $propFind->handle($ns.'supported-address-data', function () { ...
php
{ "resource": "" }
q27203
Plugin.report
train
public function report($reportName, $dom, $path) { switch ($reportName) { case '{'.self::NS_CARDDAV.'}addressbook-multiget': $this->server->transactionType = 'report-addressbook-multiget'; $this->addressbookMultiGetReport($dom); return false; ...
php
{ "resource": "" }
q27204
Plugin.getAddressbookHomeForPrincipal
train
protected function getAddressbookHomeForPrincipal($principal) { list(, $principalId) = Uri\split($principal); return self::ADDRESSBOOK_ROOT.'/'.$principalId; }
php
{ "resource": "" }
q27205
Plugin.addressbookMultiGetReport
train
public function addressbookMultiGetReport($report) { $contentType = $report->contentType; $version = $report->version; if ($version) { $contentType .= '; version='.$version; } $vcardType = $this->negotiateVCard( $contentType ); $prope...
php
{ "resource": "" }
q27206
Plugin.addressbookQueryReport
train
protected function addressbookQueryReport($report) { $depth = $this->server->getHTTPDepth(0); if (0 == $depth) { $candidateNodes = [ $this->server->tree->getNodeForPath($this->server->getRequestUri()), ]; if (!$candidateNodes[0] instanceof ICard) ...
php
{ "resource": "" }
q27207
Plugin.validateFilters
train
public function validateFilters($vcardData, array $filters, $test) { if (!$filters) { return true; } $vcard = VObject\Reader::read($vcardData); foreach ($filters as $filter) { $isDefined = isset($vcard->{$filter['name']}); if ($filter['is-not-defi...
php
{ "resource": "" }
q27208
Plugin.validateParamFilters
train
protected function validateParamFilters(array $vProperties, array $filters, $test) { foreach ($filters as $filter) { $isDefined = false; foreach ($vProperties as $vProperty) { $isDefined = isset($vProperty[$filter['name']]); if ($isDefined) { ...
php
{ "resource": "" }
q27209
Plugin.validateTextMatches
train
protected function validateTextMatches(array $texts, array $filters, $test) { foreach ($filters as $filter) { $success = false; foreach ($texts as $haystack) { $success = DAV\StringUtil::textMatch($haystack, $filter['value'], $filter['collation'], $filter['match-type'...
php
{ "resource": "" }
q27210
Plugin.propFindLate
train
public function propFindLate(DAV\PropFind $propFind, DAV\INode $node) { // If the request was made using the SOGO connector, we must rewrite // the content-type property. By default SabreDAV will send back // text/x-vcard; charset=utf-8, but for SOGO we must strip that last // part. ...
php
{ "resource": "" }
q27211
Plugin.htmlActionsPanel
train
public function htmlActionsPanel(DAV\INode $node, &$output) { if (!$node instanceof AddressBookHome) { return; } $output .= '<tr><td colspan="2"><form method="post" action=""> <h3>Create new address book</h3> <input type="hidden" name="sabreAction" value=...
php
{ "resource": "" }
q27212
Plugin.negotiateVCard
train
protected function negotiateVCard($input, &$mimeType = null) { $result = HTTP\negotiateContentType( $input, [ // Most often used mime-type. Version 3 'text/x-vcard', // The correct standard mime-type. Defaults to version 3 as ...
php
{ "resource": "" }
q27213
Plugin.convertVCard
train
protected function convertVCard($data, $target, array $propertiesFilter = null) { if (is_resource($data)) { $data = stream_get_contents($data); } $input = VObject\Reader::read($data); if (!empty($propertiesFilter)) { $propertiesFilter = array_merge(['UID', 'VE...
php
{ "resource": "" }
q27214
Plugin.getCurrentUserPrincipals
train
public function getCurrentUserPrincipals() { $currentUser = $this->getCurrentUserPrincipal(); if (is_null($currentUser)) { return []; } return array_merge( [$currentUser], $this->getPrincipalMembership($currentUser) ); }
php
{ "resource": "" }
q27215
Plugin.getPrincipalMembership
train
public function getPrincipalMembership($mainPrincipal) { // First check our cache if (isset($this->principalMembershipCache[$mainPrincipal])) { return $this->principalMembershipCache[$mainPrincipal]; } $check = [$mainPrincipal]; $principals = []; while (...
php
{ "resource": "" }
q27216
Plugin.principalMatchesPrincipal
train
public function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null) { if (is_null($currentPrincipal)) { $currentPrincipal = $this->getCurrentUserPrincipal(); } if ($currentPrincipal === $checkPrincipal) { return true; } if (is_null($cu...
php
{ "resource": "" }
q27217
Plugin.getSupportedPrivilegeSet
train
public function getSupportedPrivilegeSet($node) { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } $supportedPrivileges = null; if ($node instanceof IACL) { $supportedPrivileges = $node->getSupportedPrivilegeSet(); } ...
php
{ "resource": "" }
q27218
Plugin.getFlatPrivilegeSet
train
final public function getFlatPrivilegeSet($node) { $privs = [ 'abstract' => false, 'aggregates' => $this->getSupportedPrivilegeSet($node), ]; $fpsTraverse = null; $fpsTraverse = function ($privName, $privInfo, $concrete, &$flat) use (&$fpsTraverse) { ...
php
{ "resource": "" }
q27219
Plugin.getAcl
train
public function getAcl($node) { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } if (!$node instanceof IACL) { return $this->getDefaultAcl(); } $acl = $node->getACL(); foreach ($this->adminPrincipals as $adminPrinci...
php
{ "resource": "" }
q27220
Plugin.getCurrentUserPrivilegeSet
train
public function getCurrentUserPrivilegeSet($node) { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } $acl = $this->getACL($node); $collected = []; $isAuthenticated = null !== $this->getCurrentUserPrincipal(); foreach ($acl ...
php
{ "resource": "" }
q27221
Plugin.getPrincipalByUri
train
public function getPrincipalByUri($uri) { $result = null; $collections = $this->principalCollectionSet; foreach ($collections as $collection) { try { $principalCollection = $this->server->tree->getNodeForPath($collection); } catch (NotFound $e) { ...
php
{ "resource": "" }
q27222
Plugin.principalSearch
train
public function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null, $test = 'allof') { if (!is_null($collectionUri)) { $uris = [$collectionUri]; } else { $uris = $this->principalCollectionSet; } $lookupResults = []; ...
php
{ "resource": "" }
q27223
Plugin.beforeMethod
train
public function beforeMethod(RequestInterface $request, ResponseInterface $response) { $method = $request->getMethod(); $path = $request->getPath(); $exists = $this->server->tree->nodeExists($path); // If the node doesn't exists, none of these checks apply if (!$exists) { ...
php
{ "resource": "" }
q27224
Plugin.beforeBind
train
public function beforeBind($uri) { list($parentUri) = Uri\split($uri); $this->checkPrivileges($parentUri, '{DAV:}bind'); }
php
{ "resource": "" }
q27225
Plugin.beforeUnbind
train
public function beforeUnbind($uri) { list($parentUri) = Uri\split($uri); $this->checkPrivileges($parentUri, '{DAV:}unbind', self::R_RECURSIVEPARENTS); }
php
{ "resource": "" }
q27226
Plugin.propPatch
train
public function propPatch($path, DAV\PropPatch $propPatch) { $propPatch->handle('{DAV:}group-member-set', function ($value) use ($path) { if (is_null($value)) { $memberSet = []; } elseif ($value instanceof Href) { $memberSet = array_map( ...
php
{ "resource": "" }
q27227
Plugin.report
train
public function report($reportName, $report, $path) { switch ($reportName) { case '{DAV:}principal-property-search': $this->server->transactionType = 'report-principal-property-search'; $this->principalPropertySearchReport($path, $report); return ...
php
{ "resource": "" }
q27228
Plugin.principalMatchReport
train
protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report) { $depth = $this->server->getHTTPDepth(0); if (0 !== $depth) { throw new BadRequest('The principal-match report is only defined on Depth: 0'); } $currentPrincipals = $this->getCurren...
php
{ "resource": "" }
q27229
Plugin.expandPropertyReport
train
protected function expandPropertyReport($path, $report) { $depth = $this->server->getHTTPDepth(0); $result = $this->expandProperties($path, $report->properties, $depth); $xml = $this->server->xml->write( '{DAV:}multistatus', new DAV\Xml\Response\MultiStatus($result)...
php
{ "resource": "" }
q27230
Plugin.expandProperties
train
protected function expandProperties($path, array $requestedProperties, $depth) { $foundProperties = $this->server->getPropertiesForPath($path, array_keys($requestedProperties), $depth); $result = []; foreach ($foundProperties as $node) { foreach ($requestedProperties as $proper...
php
{ "resource": "" }
q27231
Plugin.aclPrincipalPropSetReport
train
protected function aclPrincipalPropSetReport($path, Xml\Request\AclPrincipalPropSetReport $report) { if (0 !== $this->server->getHTTPDepth(0)) { throw new BadRequest('The {DAV:}acl-principal-prop-set REPORT only supports Depth 0'); } // Fetching ACL rules for the given path. We'...
php
{ "resource": "" }
q27232
MethodNotAllowed.getHTTPHeaders
train
public function getHTTPHeaders(\Sabre\DAV\Server $server) { $methods = $server->getAllowedMethods($server->getRequestUri()); return [ 'Allow' => strtoupper(implode(', ', $methods)), ]; }
php
{ "resource": "" }
q27233
Plugin.propFind
train
public function propFind(PropFind $propFind, INode $node) { $path = $propFind->getPath(); $pathFilter = $this->pathFilter; if ($pathFilter && !$pathFilter($path)) { return; } $this->backend->propFind($propFind->getPath(), $propFind); }
php
{ "resource": "" }
q27234
Plugin.propPatch
train
public function propPatch($path, PropPatch $propPatch) { $pathFilter = $this->pathFilter; if ($pathFilter && !$pathFilter($path)) { return; } $this->backend->propPatch($path, $propPatch); }
php
{ "resource": "" }
q27235
Plugin.afterUnbind
train
public function afterUnbind($path) { $pathFilter = $this->pathFilter; if ($pathFilter && !$pathFilter($path)) { return; } $this->backend->delete($path); }
php
{ "resource": "" }
q27236
Plugin.afterMove
train
public function afterMove($source, $destination) { $pathFilter = $this->pathFilter; if ($pathFilter && !$pathFilter($source)) { return; } // If the destination is filtered, afterUnbind will handle cleaning up // the properties. if ($pathFilter && !$pathFil...
php
{ "resource": "" }
q27237
Calendar.getProperties
train
public function getProperties($requestedProperties) { $response = []; foreach ($this->calendarInfo as $propName => $propValue) { if (!is_null($propValue) && '{' === $propName[0]) { $response[$propName] = $this->calendarInfo[$propName]; } } re...
php
{ "resource": "" }
q27238
Calendar.getChild
train
public function getChild($name) { $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); if (!$obj) { throw new DAV\Exception\NotFound('Calendar object not found'); } $obj['acl'] = $this->getChildACL(); return new CalendarObject($this-...
php
{ "resource": "" }
q27239
Calendar.getChildren
train
public function getChildren() { $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); $children = []; foreach ($objs as $obj) { $obj['acl'] = $this->getChildACL(); $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj)...
php
{ "resource": "" }
q27240
Calendar.childExists
train
public function childExists($name) { $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); if (!$obj) { return false; } else { return true; } }
php
{ "resource": "" }
q27241
IMAP.imapOpen
train
protected function imapOpen($username, $password) { $success = false; try { $imap = imap_open($this->mailbox, $username, $password, OP_HALFOPEN | OP_READONLY, 1); if ($imap) { $success = true; } } catch (\ErrorException $e) { e...
php
{ "resource": "" }
q27242
UUIDUtil.getUUID
train
public static function getUUID() { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" mt_rand(0, 0xffff), mt_rand(0, 0xffff), // 16 bits for "time_mid" mt_rand(0, 0xffff), // 16 bits for "time_hi_and_version", ...
php
{ "resource": "" }
q27243
VCFExportPlugin.initialize
train
public function initialize(DAV\Server $server) { $this->server = $server; $this->server->on('method:GET', [$this, 'httpGet'], 90); $server->on('browserButtonActions', function ($path, $node, &$actions) { if ($node instanceof IAddressBook) { $actions .= '<a href="'...
php
{ "resource": "" }
q27244
VCFExportPlugin.httpGet
train
public function httpGet(RequestInterface $request, ResponseInterface $response) { $queryParams = $request->getQueryParameters(); if (!array_key_exists('export', $queryParams)) { return; } $path = $request->getPath(); $node = $this->server->tree->getNodeForPath($...
php
{ "resource": "" }
q27245
VCFExportPlugin.generateVCF
train
public function generateVCF(array $nodes) { $output = ''; foreach ($nodes as $node) { if (!isset($node[200]['{'.Plugin::NS_CARDDAV.'}address-data'])) { continue; } $nodeData = $node[200]['{'.Plugin::NS_CARDDAV.'}address-data']; // Par...
php
{ "resource": "" }
q27246
Plugin.propFind
train
public function propFind(PropFind $propFind, INode $node) { // There's a bunch of properties that must appear as a self-closing // xml-element. This event handler ensures that this will be the case. $props = [ '{http://calendarserver.org/ns/}subscribed-strip-alarms', ...
php
{ "resource": "" }
q27247
Plugin.httpPost
train
public function httpPost(RequestInterface $request, ResponseInterface $response) { // Checking if this is a text/calendar content type $contentType = $request->getHeader('Content-Type'); if (!$contentType || 0 !== strpos($contentType, 'text/calendar')) { return; } ...
php
{ "resource": "" }
q27248
Plugin.calendarObjectChange
train
public function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew) { if (!$this->scheduleReply($this->server->httpRequest)) { return; } $calendarNode = $this->server->tree->getNodeForPath($calendarPath...
php
{ "resource": "" }
q27249
Plugin.deliver
train
public function deliver(ITip\Message $iTipMessage) { $this->server->emit('schedule', [$iTipMessage]); if (!$iTipMessage->scheduleStatus) { $iTipMessage->scheduleStatus = '5.2;There was no system capable of delivering the scheduling message'; } // In case the change was co...
php
{ "resource": "" }
q27250
Plugin.beforeUnbind
train
public function beforeUnbind($path) { // FIXME: We shouldn't trigger this functionality when we're issuing a // MOVE. This is a hack. if ('MOVE' === $this->server->httpRequest->getMethod()) { return; } $node = $this->server->tree->getNodeForPath($path); ...
php
{ "resource": "" }
q27251
Plugin.getSupportedPrivilegeSet
train
public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { $ns = '{'.self::NS_CALDAV.'}'; if ($node instanceof IOutbox) { $supportedPrivilegeSet[$ns.'schedule-send'] = [ 'abstract' => false, 'aggregates' => [ ...
php
{ "resource": "" }
q27252
Plugin.processICalendarChange
train
protected function processICalendarChange($oldObject = null, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false) { $broker = new ITip\Broker(); $messages = $broker->parseEvent($newObject, $addresses, $oldObject); if ($messages) { $modified = true; ...
php
{ "resource": "" }
q27253
Plugin.getAddressesForPrincipal
train
protected function getAddressesForPrincipal($principal) { $CUAS = '{'.self::NS_CALDAV.'}calendar-user-address-set'; $properties = $this->server->getProperties( $principal, [$CUAS] ); // If we can't find this information, we'll stop processing if (!is...
php
{ "resource": "" }
q27254
Plugin.outboxRequest
train
public function outboxRequest(IOutbox $outboxNode, RequestInterface $request, ResponseInterface $response) { $outboxPath = $request->getPath(); // Parsing the request body try { $vObject = VObject\Reader::read($request->getBody()); } catch (VObject\ParseException $e) { ...
php
{ "resource": "" }
q27255
PropFind.getStatus
train
public function getStatus($propertyName) { return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : null; }
php
{ "resource": "" }
q27256
PropFind.getResultForMultiStatus
train
public function getResultForMultiStatus() { $r = [ 200 => [], 404 => [], ]; foreach ($this->result as $propertyName => $info) { if (!isset($r[$info[0]])) { $r[$info[0]] = [$propertyName => $info[1]]; } else { $r[...
php
{ "resource": "" }
q27257
Plugin.httpPatch
train
public function httpPatch(RequestInterface $request, ResponseInterface $response) { $path = $request->getPath(); // Get the node. Will throw a 404 if not found $node = $this->server->tree->getNodeForPath($path); if (!$node instanceof IPatchSupport) { throw new DAV\Except...
php
{ "resource": "" }
q27258
Plugin.getHTTPUpdateRange
train
public function getHTTPUpdateRange(RequestInterface $request) { $range = $request->getHeader('X-Update-Range'); if (is_null($range)) { return null; } // Matching "Range: bytes=1234-5678: both numbers are optional if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0...
php
{ "resource": "" }
q27259
Description.render
train
public function render(?Formatter $formatter = null): string { if ($formatter === null) { $formatter = new PassthroughFormatter(); } $tags = []; foreach ($this->tags as $tag) { $tags[] = '{' . $formatter->format($tag) . '}'; } return vsprintf...
php
{ "resource": "" }
q27260
MyTag.create
train
public static function create(string $body, DescriptionFactory $descriptionFactory = null, Context $context = null): MyTag { Assert::notNull($descriptionFactory); return new static($descriptionFactory->create($body, $context)); }
php
{ "resource": "" }
q27261
DocBlock.getTagsByName
train
public function getTagsByName(string $name): array { $result = []; /** @var Tag $tag */ foreach ($this->getTags() as $tag) { if ($tag->getName() !== $name) { continue; } $result[] = $tag; } return $result; }
php
{ "resource": "" }
q27262
DocBlock.hasTag
train
public function hasTag(string $name): bool { /** @var Tag $tag */ foreach ($this->getTags() as $tag) { if ($tag->getName() === $name) { return true; } } return false; }
php
{ "resource": "" }
q27263
DocBlock.removeTag
train
public function removeTag(Tag $tagToRemove): void { foreach ($this->tags as $key => $tag) { if ($tag === $tagToRemove) { unset($this->tags[$key]); break; } } }
php
{ "resource": "" }
q27264
Generic.create
train
public static function create( string $body, string $name = '', ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null ): self { Assert::stringNotEmpty($name); Assert::notNull($descriptionFactory); $description = $descriptionFactory && $...
php
{ "resource": "" }
q27265
Generic.validateTagName
train
private function validateTagName(string $name): void { if (! preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) { throw new \InvalidArgumentException( 'The tag name "' . $name . '" is not wellformed. Tags may only consist of letters, underscores, ' ...
php
{ "resource": "" }
q27266
DescriptionFactory.lex
train
private function lex(string $contents): array { $contents = $this->removeSuperfluousStartingWhitespace($contents); // performance optimalization; if there is no inline tag, don't bother splitting it up. if (strpos($contents, '{@') === false) { return [$contents]; } ...
php
{ "resource": "" }
q27267
DescriptionFactory.parse
train
private function parse($tokens, ?TypeContext $context = null): array { $count = count($tokens); $tagCount = 0; $tags = []; for ($i = 1; $i < $count; $i += 2) { $tags[] = $this->tagFactory->create($tokens[$i], $context); $tokens[$i] = '%' . ++$tagCount . '$s';...
php
{ "resource": "" }
q27268
DescriptionFactory.removeSuperfluousStartingWhitespace
train
private function removeSuperfluousStartingWhitespace(string $contents): string { $lines = explode("\n", $contents); // if there is only one line then we don't have lines with superfluous whitespace and // can use the contents as-is if (count($lines) <= 1) { return $conte...
php
{ "resource": "" }
q27269
DocBlockFactory.createInstance
train
public static function createInstance(array $additionalTags = []): self { $fqsenResolver = new FqsenResolver(); $tagFactory = new StandardTagFactory($fqsenResolver); $descriptionFactory = new DescriptionFactory($tagFactory); $tagFactory->addService($descriptionFactory); $tag...
php
{ "resource": "" }
q27270
DocBlockFactory.splitDocBlock
train
private function splitDocBlock(string $comment): array { // Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This // method does not split tags so we return this verbatim as the fourth result (tags). This saves us the // performance impact of...
php
{ "resource": "" }
q27271
AlignFormatter.format
train
public function format(Tag $tag): string { return '@' . $tag->getName() . str_repeat(' ', $this->maxLen - strlen($tag->getName()) + 1) . (string) $tag; }
php
{ "resource": "" }
q27272
ResponseManager.makeError
train
public static function makeError($errorCode, $message, $data = array()) { $error = array(); $error['flag'] = false; $error['message'] = $message; $error['code'] = $errorCode; if(!empty($data)) $error['data'] = $data; return $error; }
php
{ "resource": "" }
q27273
ConfigModuleService.store
train
public function store($key, $value) { return $this->configService->store($this->module, $key, $value); }
php
{ "resource": "" }
q27274
DecimalConverter.getDecimal
train
private function getDecimal(array $number) { if ($this->isStandardBase($this->source->getDigitList())) { return gmp_init(implode('', $this->source->canonizeDigits($number)), $this->source->getRadix()); } $number = $this->source->getValues($number); $decimal = gmp_init('0...
php
{ "resource": "" }
q27275
DecimalConverter.isStandardBase
train
private function isStandardBase(array $digits) { if (count($digits) > strlen(self::$standardBase)) { return false; } return $digits === str_split(substr(self::$standardBase, 0, count($digits))); }
php
{ "resource": "" }
q27276
DecimalConverter.getFractionDigitCount
train
private function getFractionDigitCount($count) { if ($this->precision > 0) { return $this->precision; } $target = gmp_init($this->target->getRadix()); $maxFraction = gmp_pow(gmp_init($this->source->getRadix()), $count); $digits = 1; while (gmp_cmp(gmp_po...
php
{ "resource": "" }
q27277
TwigAdapter.createMessage
train
public function createMessage(string $templatePath, array $context): Message { $template = $this->twig->loadTemplate($templatePath); $context = $this->twig->mergeGlobals($context); return new Message( $this->renderBlock($template, 'title', $context), $this->renderBlo...
php
{ "resource": "" }
q27278
TwigAdapter.createMessageContent
train
protected function createMessageContent(Twig_Template $template, array $context): MessageContent { $mimeType = $this->renderBlock($template, 'content_type', $context); $content = $mimeType === 'text/html' ? new HtmlMessageContent : new GenericMessageContent($mimeType); ...
php
{ "resource": "" }
q27279
AbstractService.filterFileInput
train
final protected function filterFileInput(array $files) { // Cache method calls static $filter = null; if ($filter === null) { $filter = new NameFilter(new UniqueType()); } // By reference anyway $filter->filter($files); }
php
{ "resource": "" }
q27280
AbstractService.callHydrator
train
private function callHydrator($target, array $args) { $callback = array($this, 'toEntity'); return call_user_func_array($callback, array_merge(array($target), $args)); }
php
{ "resource": "" }
q27281
AbstractService.prepareResults
train
final protected function prepareResults() { $args = func_get_args(); $array = array_shift($args); if (!empty($array)) { $result = array(); foreach ($array as $target) { array_push($result, $this->callHydrator($target, $args)); } ...
php
{ "resource": "" }
q27282
AbstractService.prepareResult
train
final protected function prepareResult() { $args = func_get_args(); $result = array_shift($args); if ($result && $result !== false) { return $this->callHydrator($result, $args); } else { return false; } }
php
{ "resource": "" }
q27283
CookieBag.removeAll
train
public function removeAll() { if (!$this->isEmpty()) { foreach ($this->getAll() as $key => $val) { $this->remove($key); } return true; } else { return false; } }
php
{ "resource": "" }
q27284
CookieBag.setEncrypted
train
public function setEncrypted($key, $value, $ttl = TimeHelper::YEAR, $path = '/', $secure = false, $httpOnly = false, $raw = false) { return $this->set($key, $this->getCrypter()->encryptValue($value), $ttl, $path, $secure, $httpOnly, $raw); }
php
{ "resource": "" }
q27285
CookieBag.get
train
public function get($key) { if ($this->has($key)) { return $this->cookies[$key]; } else { throw new RuntimeException(sprintf( 'Attempted to read non-existing cookie "%s"', $key )); } }
php
{ "resource": "" }
q27286
CookieBag.remove
train
public function remove($key) { if ($this->has($key)) { // Set cookie in the past $this->set($key, '', -86400); // And also make sure it won't be available on the current HTTP request unset($this->cookies[$key]); return true; } else { ...
php
{ "resource": "" }
q27287
Sensors.createRandom
train
public static function createRandom($passes = 1) : self { for($i = 0; $i < $passes; $i++) { $sensor = new self( Random::randomFloat(-0.3, 0.3), Random::randomFloat(-0.2, 2.5), Random::randomFloat(-0.2, 5), Random::randomFloat(0.08, ...
php
{ "resource": "" }
q27288
IntegerDigitList.buildDigitList
train
private function buildDigitList($radix) { if ($radix <= strlen(self::$integerBase)) { return str_split(substr(self::$integerBase, 0, $radix)); } elseif ($radix === 64) { return str_split(self::$integerBase64); } elseif ($radix <= 256) { return range(chr(0)...
php
{ "resource": "" }
q27289
IntegerDigitList.buildArbitraryList
train
private function buildArbitraryList($radix) { $format = '#%0' . strlen($radix - 1) . 'd'; return array_map(function ($value) use ($format) { return sprintf($format, $value); }, range(0, $radix - 1)); }
php
{ "resource": "" }
q27290
BasicAuthClient.executeQuery
train
protected function executeQuery( $uri, $type = self::HTTP_GET, $variables = [], $contentType = self::CONTENT_TYPE_FORM ) : BookboonResponse { $http = curl_init(); $headers = $this->getHeaders()->getAll(); if ($type === self::HTTP_POST) { $encoded...
php
{ "resource": "" }
q27291
Captcha.isValid
train
public function isValid($answer) { // Compare shouldn't be strict, since we might compare a string against a number if ($this->storage->get() == $answer) { return true; } else { $this->error = 'Invalid answer provided'; return false; } }
php
{ "resource": "" }
q27292
Service.execute
train
public function execute(Request $request, Position $position) { $response = $this->batchExecute([$request], $position); return $request->getResponse(current($response)); }
php
{ "resource": "" }
q27293
Service.setEndpoint
train
protected function setEndpoint(string $endpoint) { $fullEndpoint = 'https://' . $endpoint . '/rpc'; if (!empty($endpoint) && $fullEndpoint !== $this->endpoint) { $this->endpoint = $fullEndpoint; } }
php
{ "resource": "" }
q27294
Service.createEnvelope
train
protected function createEnvelope(array $requests, Position $position) : RequestEnvelope { $authInfo = null; $envelope = new RequestEnvelope(); $envelope->setStatusCode(2); $envelope->setLatitude($position->getLatitude()); $envelope->setLongitude($position->getLongitude()); ...
php
{ "resource": "" }
q27295
Service.generateLocationFixes
train
protected function generateLocationFixes(Position $position) : array { $amount = rand(3,5); $fixes = []; for($i = 0; $i < $amount; $i++) { $fixes[] = $this->generateLocationFix($position); } return $fixes; }
php
{ "resource": "" }
q27296
Service.generateLocationFix
train
protected function generateLocationFix(Position $position) : Signature\LocationFix { $location = $position->createRandomized(); $locationFix = new Signature\LocationFix(); $locationFix->setProvider("network"); $locationFix->setProviderStatus(3); $locationFix->setLocationType...
php
{ "resource": "" }
q27297
Service.generateSensorInfo
train
protected function generateSensorInfo() : MessageCollection { $list = new MessageCollection(); $sensorData = Sensors::createRandom(3); /* Fetch data */ $rawAccell = $sensorData->getAccelerometerData(); $normAccell = $sensorData->getNormalizedAccelerometerData(); ...
php
{ "resource": "" }
q27298
ExpiryDate.getExpiration
train
public function getExpiration() { $dateTime = new DateTime(); return $dateTime ->setDate($this->year, $this->month, $this->getMonthDays()) ->setTime(23, 59, 59); }
php
{ "resource": "" }
q27299
ProjectTypeFactory.createInstance
train
public function createInstance() { $classname = $this->getProjectClassname(); if (!class_exists($classname)) { throw new \Exception( sprintf('Unable to locate class %s', $classname) ); } return new $classname(); }
php
{ "resource": "" }