_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q242800
DeserializesAttributes.fillAttributes
validation
protected function fillAttributes($record, Collection $attributes) { $record->fill( $this->deserializeAttributes($attributes, $record) ); }
php
{ "resource": "" }
q242801
DeserializesAttributes.modelKeyForField
validation
protected function modelKeyForField($field, $model) { if (isset($this->attributes[$field])) { return $this->attributes[$field]; } $key = $model::$snakeAttributes ? Str::underscore($field) : Str::camelize($field); return $this->attributes[$field] = $key; }
php
{ "resource": "" }
q242802
DeserializesAttributes.deserializeAttributes
validation
protected function deserializeAttributes($attributes, $record) { return collect($attributes)->reject(function ($v, $field) use ($record) { return $this->isNotFillable($field, $record); })->mapWithKeys(function ($value, $field) use ($record) { $key = $this->modelKeyForField($f...
php
{ "resource": "" }
q242803
DeserializesAttributes.deserializeAttribute
validation
protected function deserializeAttribute($value, $field, $record) { if ($this->isDateAttribute($field, $record)) { return $this->deserializeDate($value, $field, $record); } $method = 'deserialize' . Str::classify($field) . 'Field'; if (method_exists($this, $method)) { ...
php
{ "resource": "" }
q242804
DeserializesAttributes.isDateAttribute
validation
protected function isDateAttribute($field, $record) { if (empty($this->dates)) { return in_array($this->modelKeyForField($field, $record), $record->getDates(), true); } return in_array($field, $this->dates, true); }
php
{ "resource": "" }
q242805
ClientJob.setResource
validation
public function setResource($resource): ClientJob { $schema = $this->getApi()->getContainer()->getSchema($resource); $this->fill([ 'resource_type' => $schema->getResourceType(), 'resource_id' => $schema->getId($resource), ]); return $this; }
php
{ "resource": "" }
q242806
ClientJob.getResource
validation
public function getResource() { if (!$this->resource_type || !$this->resource_id) { return null; } return $this->getApi()->getStore()->find( ResourceIdentifier::create($this->resource_type, (string) $this->resource_id) ); }
php
{ "resource": "" }
q242807
Route.substituteBindings
validation
public function substituteBindings(StoreInterface $store): void { /** Cache the ID values so that we still have access to them. */ $this->resourceId = $this->getResourceId() ?: false; $this->processId = $this->getProcessId() ?: false; /** Bind the domain record. */ if ($this...
php
{ "resource": "" }
q242808
Route.getType
validation
public function getType(): string { if ($resource = $this->getResource()) { return get_class($resource); } $resourceType = $this->getResourceType(); if (!$type = $this->resolver->getType($resourceType)) { throw new RuntimeException("JSON API resource type {$...
php
{ "resource": "" }
q242809
Route.getResourceId
validation
public function getResourceId(): ?string { if (is_null($this->resourceId)) { return $this->parameter(ResourceRegistrar::PARAM_RESOURCE_ID); } return $this->resourceId ?: null; }
php
{ "resource": "" }
q242810
Route.getResourceIdentifier
validation
public function getResourceIdentifier(): ?ResourceIdentifierInterface { if (!$resourceId = $this->getResourceId()) { return null; } return ResourceIdentifier::create($this->getResourceType(), $resourceId); }
php
{ "resource": "" }
q242811
Route.getResource
validation
public function getResource() { $resource = $this->parameter(ResourceRegistrar::PARAM_RESOURCE_ID); return is_object($resource) ? $resource : null; }
php
{ "resource": "" }
q242812
Route.getProcessId
validation
public function getProcessId(): ?string { if (is_null($this->processId)) { return $this->parameter(ResourceRegistrar::PARAM_PROCESS_ID); } return $this->processId ?: null; }
php
{ "resource": "" }
q242813
Route.getProcess
validation
public function getProcess(): ?AsynchronousProcess { $process = $this->parameter(ResourceRegistrar::PARAM_PROCESS_ID); return ($process instanceof AsynchronousProcess) ? $process : null; }
php
{ "resource": "" }
q242814
Route.getProcessIdentifier
validation
public function getProcessIdentifier(): ?ResourceIdentifierInterface { if (!$id = $this->getProcessId()) { return null; } return ResourceIdentifier::create($this->getProcessType(), $id); }
php
{ "resource": "" }
q242815
JsonApiService.defaultApi
validation
public function defaultApi($apiName = null) { if (is_null($apiName)) { return LaravelJsonApi::$defaultApi; } LaravelJsonApi::defaultApi($apiName); return $apiName; }
php
{ "resource": "" }
q242816
JsonApiService.api
validation
public function api($apiName = null) { /** @var Repository $repo */ $repo = $this->container->make(Repository::class); return $repo->createApi($apiName ?: $this->defaultApi()); }
php
{ "resource": "" }
q242817
JsonApiService.register
validation
public function register($apiName, $options = [], Closure $routes = null): ApiRegistration { /** @var JsonApiRegistrar $registrar */ $registrar = $this->container->make('json-api.registrar'); return $registrar->api($apiName, $options, $routes); }
php
{ "resource": "" }
q242818
CreateResource.validateDocumentCompliance
validation
protected function validateDocumentCompliance($document, ?ValidatorFactoryInterface $validators): void { $this->passes( $this->factory->createNewResourceDocumentValidator( $document, $this->getResourceType(), $validators && $validators->supportsCli...
php
{ "resource": "" }
q242819
ResourceObject.create
validation
public static function create(array $data): self { if (!isset($data['type'])) { throw new \InvalidArgumentException('Expecting a resource type.'); } return new self( $data['type'], $data['id'] ?? null, $data['attributes'] ?? [], $d...
php
{ "resource": "" }
q242820
ResourceObject.withType
validation
public function withType(string $type): self { if (empty($type)) { throw new \InvalidArgumentException('Expecting a non-empty string.'); } $copy = clone $this; $copy->type = $type; $copy->normalize(); return $copy; }
php
{ "resource": "" }
q242821
ResourceObject.withId
validation
public function withId(?string $id): self { $copy = clone $this; $copy->id = $id ?: null; $copy->normalize(); return $copy; }
php
{ "resource": "" }
q242822
ResourceObject.withAttributes
validation
public function withAttributes($attributes): self { $copy = clone $this; $copy->attributes = collect($attributes)->all(); $copy->normalize(); return $copy; }
php
{ "resource": "" }
q242823
ResourceObject.withRelationships
validation
public function withRelationships($relationships): self { $copy = clone $this; $copy->relationships = collect($relationships)->all(); $copy->normalize(); return $copy; }
php
{ "resource": "" }
q242824
ResourceObject.getRelations
validation
public function getRelations(): Collection { return $this->getRelationships()->filter(function (array $relation) { return array_key_exists('data', $relation); })->map(function (array $relation) { return $relation['data']; }); }
php
{ "resource": "" }
q242825
ResourceObject.withMeta
validation
public function withMeta($meta): self { $copy = clone $this; $copy->meta = collect($meta)->all(); return $copy; }
php
{ "resource": "" }
q242826
ResourceObject.withLinks
validation
public function withLinks($links): self { $copy = clone $this; $copy->links = collect($links)->all(); return $copy; }
php
{ "resource": "" }
q242827
ResourceObject.pointer
validation
public function pointer(string $key, string $prefix = ''): string { $prefix = rtrim($prefix, '/'); if ('type' === $key) { return $prefix . '/type'; } if ('id' === $key) { return $prefix . '/id'; } $parts = collect(explode('.', $key)); ...
php
{ "resource": "" }
q242828
ResourceObject.pointerForRelationship
validation
public function pointerForRelationship(string $key, string $default = '/'): string { $field = collect(explode('.', $key))->first(); if (!$this->isRelationship($field)) { throw new \InvalidArgumentException("Field {$field} is not a relationship."); } $pointer = $this->po...
php
{ "resource": "" }
q242829
MetaMemberTrait.getMeta
validation
public function getMeta() { $meta = $this->hasMeta() ? $this->get(DocumentInterface::KEYWORD_META) : new StandardObject(); if (!is_null($meta) && !$meta instanceof StandardObjectInterface) { throw new RuntimeException('Data member is not an object.'); } return $meta; ...
php
{ "resource": "" }
q242830
InvokesHooks.invoke
validation
protected function invoke(string $hook, ...$arguments) { if (!method_exists($this, $hook)) { return null; } $result = $this->{$hook}(...$arguments); return $this->isInvokedResult($result) ? $result : null; }
php
{ "resource": "" }
q242831
InvokesHooks.invokeMany
validation
protected function invokeMany(iterable $hooks, ...$arguments) { foreach ($hooks as $hook) { $result = $this->invoke($hook, ...$arguments); if (!is_null($result)) { return $result; } } return null; }
php
{ "resource": "" }
q242832
CreateResourceValidator.validateData
validation
protected function validateData(): bool { if (!property_exists($this->document, 'data')) { $this->memberRequired('/', 'data'); return false; } $data = $this->document->data; if (!is_object($data)) { $this->memberNotObject('/', 'data'); ...
php
{ "resource": "" }
q242833
CreateResourceValidator.validateResource
validation
protected function validateResource(): bool { $identifier = $this->validateTypeAndId(); $attributes = $this->validateAttributes(); $relationships = $this->validateRelationships(); if ($attributes && $relationships) { return $this->validateAllFields() && $identifier; ...
php
{ "resource": "" }
q242834
CreateResourceValidator.validateTypeAndId
validation
protected function validateTypeAndId(): bool { if (!($this->validateType() && $this->validateId())) { return false; } $type = $this->dataGet('type'); $id = $this->dataGet('id'); if ($id && !$this->isNotFound($type, $id)) { $this->resourceExists($type...
php
{ "resource": "" }
q242835
CreateResourceValidator.validateType
validation
protected function validateType(): bool { if (!$this->dataHas('type')) { $this->memberRequired('/data', 'type'); return false; } $value = $this->dataGet('type'); if (!$this->validateTypeMember($value, '/data')) { return false; } ...
php
{ "resource": "" }
q242836
CreateResourceValidator.validateId
validation
protected function validateId(): bool { if (!$this->dataHas('id')) { return true; } $valid = $this->validateIdMember($this->dataGet('id'), '/data'); if (!$this->supportsClientIds()) { $valid = false; $this->resourceDoesNotSupportClientIds($this->...
php
{ "resource": "" }
q242837
CreateResourceValidator.validateAttributes
validation
protected function validateAttributes(): bool { if (!$this->dataHas('attributes')) { return true; } $attrs = $this->dataGet('attributes'); if (!is_object($attrs)) { $this->memberNotObject('/data', 'attributes'); return false; } $...
php
{ "resource": "" }
q242838
CreateResourceValidator.validateRelationships
validation
protected function validateRelationships(): bool { if (!$this->dataHas('relationships')) { return true; } $relationships = $this->dataGet('relationships'); if (!is_object($relationships)) { $this->memberNotObject('/data', 'relationships'); return...
php
{ "resource": "" }
q242839
CreateResourceValidator.validateAllFields
validation
protected function validateAllFields(): bool { $duplicates = collect( (array) $this->dataGet('attributes', []) )->intersectByKeys( (array) $this->dataGet('relationships', []) )->keys(); $this->resourceFieldsExistInAttributesAndRelationships($duplicates); ...
php
{ "resource": "" }
q242840
AuthorizesRequests.authenticate
validation
protected function authenticate() { if (empty($this->guards) && Auth::check()) { return; } foreach ($this->guards as $guard) { if (Auth::guard($guard)->check()) { Auth::shouldUse($guard); return; } } throw ...
php
{ "resource": "" }
q242841
ClientSerializer.serialize
validation
public function serialize($record, $meta = null, array $links = []) { $serializer = clone $this->serializer; $serializer->withMeta($meta)->withLinks($links); $serialized = $serializer->serializeData($record, $this->createEncodingParameters()); $resourceLinks = null; if (empt...
php
{ "resource": "" }
q242842
SeoService.injectRobots
validation
public function injectRobots () { $headers = \Craft::$app->getResponse()->getHeaders(); // If devMode always noindex if (\Craft::$app->config->general->devMode) { $headers->set('x-robots-tag', 'none, noimageindex'); return; } list($field, $element) = $this->_getElementAndSeoFields(); // Robots ...
php
{ "resource": "" }
q242843
SeoData._getSocialFallback
validation
private function _getSocialFallback () { $image = null; $assets = \Craft::$app->assets; $fieldFallback = $this->_fieldSettings['socialImage']; if (!empty($fieldFallback)) $image = $assets->getAssetById((int)$fieldFallback[0]); else { $seoFallback = $this->_seoSettings['socialImage']; if (!empty...
php
{ "resource": "" }
q242844
SeoData._getVariables
validation
private function _getVariables () { $variables = $this->_overrideObject; if ($this->_element !== null) { foreach ($this->_element->attributes() as $name) if ($name !== $this->_handle) $variables[$name] = $this->_element->$name; $variables = array_merge( $variables, $this->_element->toArr...
php
{ "resource": "" }
q242845
RedirectsService.onException
validation
public function onException (ExceptionEvent $event) { $exception = $event->exception; $craft = \Craft::$app; if (!($exception instanceof HttpException) || $exception->statusCode !== 404) return; $path = $craft->request->getFullPath(); $query = $craft->request->getQueryStringWithoutPath(); if ($query)...
php
{ "resource": "" }
q242846
RedirectsService.findAllRedirects
validation
public function findAllRedirects ($currentSiteOnly = false) { if ($currentSiteOnly) return RedirectRecord::find()->where( '[[siteId]] IS NULL OR [[siteId]] = ' . \Craft::$app->sites->currentSite->id )->orderBy('siteId asc')->all(); return array_reduce( RedirectRecord::find()->all(), function (...
php
{ "resource": "" }
q242847
RedirectsService.findRedirectByPath
validation
public function findRedirectByPath ($path) { $redirects = $this->findAllRedirects(true); foreach ($redirects as $redirect) { $to = false; if (trim($redirect['uri'], '/') == $path) $to = $redirect['to']; elseif ($uri = $this->_isRedirectRegex($redirect['uri'])) if (preg_match($uri, $path)) ...
php
{ "resource": "" }
q242848
RedirectsService.save
validation
public function save ($uri, $to, $type, $siteId = null, $id = null) { if ($siteId === 'null') $siteId = null; if ($id) { $record = RedirectRecord::findOne(compact('id')); if (!$record) return 'Unable to find redirect with ID: ' . $id; } else { $existing = RedirectRecord::findOne(compact('...
php
{ "resource": "" }
q242849
RedirectsService.bulk
validation
public function bulk ($redirects, $separator, $type, $siteId) { $rawRedirects = array_map(function ($line) use ($separator) { return str_getcsv($line, $separator); }, explode(PHP_EOL, $redirects)); $newFormatted = []; foreach ($rawRedirects as $redirect) { $record = new RedirectRecord(); $record->...
php
{ "resource": "" }
q242850
RedirectsService.delete
validation
public function delete ($id) { $redirect = RedirectRecord::findOne(compact('id'))->delete(); if ($redirect === false) return 'Unable find redirect with ID: ' . $id; return false; }
php
{ "resource": "" }
q242851
RedirectsService._isRedirectRegex
validation
private function _isRedirectRegex ($uri) { // If the URI doesn't look like a regex... if (preg_match('/\/(.*)\/([g|m|i|x|X|s|u|U|A|J|D]+)/m', $uri) === 0) { // Escape all non-escaped `?` not inside parentheses $i = preg_match_all( '/(?<!\\\\)\?(?![^(]*\))/', $uri, $matches, PREG_OFFSET_CAPT...
php
{ "resource": "" }
q242852
SitemapService._createDocument
validation
private function _createDocument ($withUrlSet = true) { // Create the XML Document $document = new \DOMDocument('1.0', 'utf-8'); // Pretty print for debugging if (\Craft::$app->config->general->devMode) $document->formatOutput = true; if ($withUrlSet) { $urlSet = $document->createElement('urlset');...
php
{ "resource": "" }
q242853
SitemapService._setCriteriaIdByType
validation
private function _setCriteriaIdByType ($criteria, Element $type, $id) { switch ($type::className()) { case 'Entry': $criteria->sectionId = $id; break; case 'Category': $criteria->groupId = $id; break; } }
php
{ "resource": "" }
q242854
Connection.close
validation
public function close() { if ($this->_socket !== false) { $connection = ($this->unixSocket ?: $this->hostname . ':' . $this->port) . ', database=' . $this->database; \Yii::trace('Closing DB connection: ' . $connection, __METHOD__); try { $this->executeComm...
php
{ "resource": "" }
q242855
Connection.sendCommandInternal
validation
private function sendCommandInternal($command, $params) { $written = @fwrite($this->_socket, $command); if ($written === false) { throw new SocketException("Failed to write to socket.\nRedis command was: " . $command); } if ($written !== ($len = mb_strlen($command, '8bit'...
php
{ "resource": "" }
q242856
Session.readSession
validation
public function readSession($id) { $data = $this->redis->executeCommand('GET', [$this->calculateKey($id)]); return $data === false || $data === null ? '' : $data; }
php
{ "resource": "" }
q242857
ActiveQuery.count
validation
public function count($q = '*', $db = null) { if ($this->emulateExecution) { return 0; } if ($this->where === null) { /* @var $modelClass ActiveRecord */ $modelClass = $this->modelClass; if ($db === null) { $db = $modelClass::g...
php
{ "resource": "" }
q242858
ActiveQuery.column
validation
public function column($column, $db = null) { if ($this->emulateExecution) { return []; } // TODO add support for orderBy return $this->executeScript($db, 'Column', $column); }
php
{ "resource": "" }
q242859
ActiveQuery.scalar
validation
public function scalar($attribute, $db = null) { if ($this->emulateExecution) { return null; } $record = $this->one($db); if ($record !== null) { return $record->hasAttribute($attribute) ? $record->$attribute : null; } else { return null; ...
php
{ "resource": "" }
q242860
LuaScriptBuilder.buildAll
validation
public function buildAll($query) { /* @var $modelClass ActiveRecord */ $modelClass = $query->modelClass; $key = $this->quoteValue($modelClass::keyPrefix() . ':a:'); return $this->build($query, "n=n+1 pks[n]=redis.call('HGETALL',$key .. pk)", 'pks'); }
php
{ "resource": "" }
q242861
LuaScriptBuilder.buildOne
validation
public function buildOne($query) { /* @var $modelClass ActiveRecord */ $modelClass = $query->modelClass; $key = $this->quoteValue($modelClass::keyPrefix() . ':a:'); return $this->build($query, "do return redis.call('HGETALL',$key .. pk) end", 'pks'); }
php
{ "resource": "" }
q242862
LuaScriptBuilder.buildColumn
validation
public function buildColumn($query, $column) { // TODO add support for indexBy /* @var $modelClass ActiveRecord */ $modelClass = $query->modelClass; $key = $this->quoteValue($modelClass::keyPrefix() . ':a:'); return $this->build($query, "n=n+1 pks[n]=redis.call('HGET',$key ....
php
{ "resource": "" }
q242863
LuaScriptBuilder.addColumn
validation
private function addColumn($column, &$columns) { if (isset($columns[$column])) { return $columns[$column]; } $name = 'c' . preg_replace("/[^a-z]+/i", "", $column) . count($columns); return $columns[$column] = $name; }
php
{ "resource": "" }
q242864
LuaScriptBuilder.buildCondition
validation
public function buildCondition($condition, &$columns) { static $builders = [ 'not' => 'buildNotCondition', 'and' => 'buildAndCondition', 'or' => 'buildAndCondition', 'between' => 'buildBetweenCondition', 'not between' => 'buildBetweenCondition', ...
php
{ "resource": "" }
q242865
Mutex.releaseLock
validation
protected function releaseLock($name) { static $releaseLuaScript = <<<LUA if redis.call("GET",KEYS[1])==ARGV[1] then return redis.call("DEL",KEYS[1]) else return 0 end LUA; if (!isset($this->_lockValues[$name]) || !$this->redis->executeCommand('EVAL', [ $releaseLuaScript, ...
php
{ "resource": "" }
q242866
ActiveRecord.updateAllCounters
validation
public static function updateAllCounters($counters, $condition = null) { if (empty($counters)) { return 0; } $db = static::getDb(); $n = 0; foreach (self::fetchPks($condition) as $pk) { $key = static::keyPrefix() . ':a:' . static::buildKey($pk); ...
php
{ "resource": "" }
q242867
ActiveRecord.buildKey
validation
public static function buildKey($key) { if (is_numeric($key)) { return $key; } elseif (is_string($key)) { return ctype_alnum($key) && StringHelper::byteLength($key) <= 32 ? $key : md5($key); } elseif (is_array($key)) { if (count($key) == 1) { ...
php
{ "resource": "" }
q242868
MultiLogger.useFiles
validation
public function useFiles($path, $level = 'debug') { foreach ($this->loggers as $logger) { if ($logger instanceof Log) { $logger->useFiles($path, $level); } } }
php
{ "resource": "" }
q242869
MultiLogger.useDailyFiles
validation
public function useDailyFiles($path, $days = 0, $level = 'debug') { foreach ($this->loggers as $logger) { if ($logger instanceof Log) { $logger->useDailyFiles($path, $days, $level); } } }
php
{ "resource": "" }
q242870
MultiLogger.getMonolog
validation
public function getMonolog() { foreach ($this->loggers as $logger) { if (is_callable([$logger, 'getMonolog'])) { $monolog = $logger->getMonolog(); if ($monolog === null) { continue; } return $monolog; ...
php
{ "resource": "" }
q242871
LaravelResolver.resolve
validation
public function resolve() { $request = $this->app->make(Request::class); if ($this->app->runningInConsole()) { $command = $request->server('argv', []); if (!is_array($command)) { $command = explode(' ', $command); } return new Console...
php
{ "resource": "" }
q242872
LaravelRequest.getMetaData
validation
public function getMetaData() { $data = []; $data['url'] = $this->request->fullUrl(); $data['httpMethod'] = $this->request->getMethod(); $data['params'] = $this->request->input(); $data['clientIp'] = $this->request->getClientIp(); if ($agent = $this->request->hea...
php
{ "resource": "" }
q242873
EventTrait.log
validation
public function log($level, $message, array $context = []) { parent::log($level, $message, $context); $this->fireLogEvent($level, $message, $context); }
php
{ "resource": "" }
q242874
EventTrait.fireLogEvent
validation
protected function fireLogEvent($level, $message, array $context = []) { // If the event dispatcher is set, we will pass along the parameters to the // log listeners. These are useful for building profilers or other tools // that aggregate all of the log messages for a given "request" cycle....
php
{ "resource": "" }
q242875
AuthServiceProvider.boot
validation
public function boot() { // Here you may define how you wish users to be authenticated for your Lumen // application. The callback which receives the incoming request instance // should return either a User instance or null. You're free to obtain // the User instance via an API token...
php
{ "resource": "" }
q242876
BugsnagServiceProvider.setupEvents
validation
protected function setupEvents(Dispatcher $events, array $config) { if (isset($config['auto_capture_sessions']) && $config['auto_capture_sessions']) { $events->listen(RouteMatched::class, function ($event) { $this->app->bugsnag->getSessionTracker()->startSession(); })...
php
{ "resource": "" }
q242877
BugsnagServiceProvider.formatQuery
validation
protected function formatQuery($sql, array $bindings, $time, $connection) { $data = ['sql' => $sql]; foreach ($bindings as $index => $binding) { $data["binding {$index}"] = $binding; } $data['time'] = "{$time}ms"; $data['connection'] = $connection; retu...
php
{ "resource": "" }
q242878
BugsnagServiceProvider.setupQueue
validation
protected function setupQueue(QueueManager $queue) { $queue->looping(function () { $this->app->bugsnag->flush(); $this->app->bugsnag->clearBreadcrumbs(); $this->app->make(Tracker::class)->clear(); }); if (!class_exists(JobProcessing::class)) { ...
php
{ "resource": "" }
q242879
BugsnagServiceProvider.getGuzzle
validation
protected function getGuzzle(array $config) { $options = []; if (isset($config['proxy']) && $config['proxy']) { if (isset($config['proxy']['http']) && php_sapi_name() != 'cli') { unset($config['proxy']['http']); } $options['proxy'] = $config['pro...
php
{ "resource": "" }
q242880
BugsnagServiceProvider.setupCallbacks
validation
protected function setupCallbacks(Client $client, Container $app, array $config) { if (!isset($config['callbacks']) || $config['callbacks']) { $client->registerDefaultCallbacks(); $client->registerCallback(function (Report $report) use ($app) { $tracker = $app->make(...
php
{ "resource": "" }
q242881
BugsnagServiceProvider.setupPaths
validation
protected function setupPaths(Client $client, $base, $path, $strip, $project) { if ($strip) { $client->setStripPath($strip); if (!$project) { $client->setProjectRoot("{$strip}/app"); } return; } if ($project) { if...
php
{ "resource": "" }
q242882
BugsnagServiceProvider.setupSessionTracking
validation
protected function setupSessionTracking(Client $client, $endpoint, $events) { $client->setAutoCaptureSessions(true); if (!is_null($endpoint)) { $client->setSessionEndpoint($endpoint); } $sessionTracker = $client->getSessionTracker(); $sessionStorage = function ($...
php
{ "resource": "" }
q242883
CoordinateFactory.fromString
validation
public static function fromString(string $string, Ellipsoid $ellipsoid = null): Coordinate { $string = self::mergeSecondsToMinutes($string); $result = self::parseDecimalMinutesWithoutCardinalLetters($string, $ellipsoid); if ($result instanceof Coordinate) { return $result; ...
php
{ "resource": "" }
q242884
Bounds.getCenter
validation
public function getCenter(): Coordinate { $centerLat = ($this->getNorth() + $this->getSouth()) / 2; return new Coordinate($centerLat, $this->getCenterLng()); }
php
{ "resource": "" }
q242885
SimplifyBearing.simplify
validation
public function simplify(Polyline $polyline): Polyline { $counterPoints = $polyline->getNumberOfPoints(); if ($counterPoints < 3) { return clone $polyline; } $result = new Polyline(); $bearingCalc = new BearingEllipsoidal(); $points = $polyline->ge...
php
{ "resource": "" }
q242886
Coordinate.getDistance
validation
public function getDistance(Coordinate $coordinate, DistanceInterface $calculator): float { return $calculator->getDistance($this, $coordinate); }
php
{ "resource": "" }
q242887
Polyline.getLength
validation
public function getLength(DistanceInterface $calculator): float { $distance = 0.0; if (count($this->points) <= 1) { return $distance; } foreach ($this->getSegments() as $segment) { $distance += $segment->getLength($calculator); } return $dis...
php
{ "resource": "" }
q242888
BearingSpherical.calculateBearing
validation
public function calculateBearing(Coordinate $point1, Coordinate $point2): float { $lat1 = deg2rad($point1->getLat()); $lat2 = deg2rad($point2->getLat()); $lng1 = deg2rad($point1->getLng()); $lng2 = deg2rad($point2->getLng()); $y = sin($lng2 - $lng1) * cos($lat2); $x ...
php
{ "resource": "" }
q242889
BearingSpherical.calculateFinalBearing
validation
public function calculateFinalBearing(Coordinate $point1, Coordinate $point2): float { $initialBearing = $this->calculateBearing($point2, $point1); return fmod($initialBearing + 180, 360); }
php
{ "resource": "" }
q242890
Polygon.getLats
validation
public function getLats(): array { $lats = []; foreach ($this->points as $point) { /** @var Coordinate $point */ $lats[] = $point->getLat(); } return $lats; }
php
{ "resource": "" }
q242891
Polygon.getLngs
validation
public function getLngs(): array { $lngs = []; foreach ($this->points as $point) { /** @var Coordinate $point */ $lngs[] = $point->getLng(); } return $lngs; }
php
{ "resource": "" }
q242892
Polygon.containsGeometry
validation
public function containsGeometry(GeometryInterface $geometry): bool { $geometryInPolygon = true; foreach ($geometry->getPoints() as $point) { $geometryInPolygon = $geometryInPolygon && $this->contains($point); } return $geometryInPolygon; }
php
{ "resource": "" }
q242893
Polygon.getPerimeter
validation
public function getPerimeter(DistanceInterface $calculator): float { $perimeter = 0.0; if (count($this->points) < 2) { return $perimeter; } foreach ($this->getSegments() as $segment) { $perimeter += $segment->getLength($calculator); } return...
php
{ "resource": "" }
q242894
Polygon.getArea
validation
public function getArea(): float { $area = 0; if ($this->getNumberOfPoints() <= 2) { return $area; } $referencePoint = $this->points[0]; $radius = $referencePoint->getEllipsoid()->getArithmeticMeanRadius(); $segments = $this->getSegments();...
php
{ "resource": "" }
q242895
Polygon.getReverse
validation
public function getReverse(): Polygon { $reversed = new static(); foreach (array_reverse($this->points) as $point) { $reversed->addPoint($point); } return $reversed; }
php
{ "resource": "" }
q242896
Client.handleConnectedSocks
validation
public function handleConnectedSocks(ConnectionInterface $stream, $host, $port, Deferred $deferred, $uri) { $reader = new StreamReader(); $stream->on('data', array($reader, 'write')); $stream->on('error', $onError = function (Exception $e) use ($deferred, $uri) { $deferred->reje...
php
{ "resource": "" }
q242897
Conversation.add
validation
public function add($message) { if (is_string($message)) { $this->messages[] = new SimpleResponse($message); } elseif ($message instanceof ResponseInterface) { $this->messages[] = $message; } elseif ($message instanceof QuestionInterface) { $this->messages...
php
{ "resource": "" }
q242898
Arguments.get
validation
public function get($name) { foreach ($this->arguments as $argument) { if ($argument['name'] == $name) { if (isset($this->mapArgumentName[$name])) { return $this->{$this->mapArgumentName[$name]}($argument); } else { return $...
php
{ "resource": "" }
q242899
Arguments.getDateTime
validation
private function getDateTime($argument) { $datetimeValue = $argument['datetimeValue']; $year = $datetimeValue['date']['year']; $month = $datetimeValue['date']['month']; $day = $datetimeValue['date']['day']; $hours = $datetimeValue['time']['hours']; $minutes = isset(...
php
{ "resource": "" }