_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q248200
CartListener.updateExpiresAt
validation
protected function updateExpiresAt(CartInterface $cart) { $date = new \DateTime(); $date->modify($this->expirationDelay); $cart->setExpiresAt($date); return true; }
php
{ "resource": "" }
q248201
Epoch.dt
validation
public static function dt(AstroDate $dt) { $epoch = new static($dt->toTT()->toJD()); $epoch->dt = $dt->copy(); return $epoch; }
php
{ "resource": "" }
q248202
Epoch.J
validation
public static function J($year) { // Get JD of the epoch $jd = static::J2000()->jd + ($year - 2000) * static::DaysJulianYear; // Create and return new epoch $epoch = new static($jd); $epoch->type = YearType::Julian(); return $epoch; }
php
{ "resource": "" }
q248203
Epoch.B
validation
public static function B($year) { // Get JD of the epoch $jd = static::B1900()->jd + ($year - 1900) * static::DaysBesselianYear; // Create and return new epoch $epoch = new static($jd); $epoch->type = YearType::Besselian(); return $epoch; }
php
{ "resource": "" }
q248204
Epoch.toDate
validation
public function toDate() { if ($this->dt) return $this->dt; else return AstroDate::jd($this->jd, TimeScale::TT()); }
php
{ "resource": "" }
q248205
Epoch.getYear
validation
protected function getYear() { $year = 0; if ($this->type == YearType::Besselian()) $year = 1900 + ($this->jd - Epoch::B1900()->jd) / static::DaysBesselianYear; else $year = 2000 + ($this->jd - Epoch::J2000()->jd) / static::DaysJulianYear; return round($year, 6); }
php
{ "resource": "" }
q248206
IdentityTrait.isIdentityEmpty
validation
public function isIdentityEmpty() { return empty($this->gender) && empty($this->firstName) && empty($this->lastName); }
php
{ "resource": "" }
q248207
IdentityTrait.clearIdentity
validation
public function clearIdentity() { $this->gender = null; $this->firstName = null; $this->lastName = null; return $this; }
php
{ "resource": "" }
q248208
DocumentCalculator.calculateGoodLines
validation
protected function calculateGoodLines(Model\DocumentInterface $document): Amount { $gross = new Amount($document->getCurrency()); foreach ($document->getLinesByType(Model\DocumentLineTypes::TYPE_GOOD) as $line) { if (null !== $result = $this->calculateGoodLine($line)) { $gross->merge($result); } } $gross->copyGrossToUnit(); return $gross; }
php
{ "resource": "" }
q248209
DocumentCalculator.calculateGoodLine
validation
protected function calculateGoodLine(Model\DocumentLineInterface $line): ?Amount { if ($line->getType() !== Model\DocumentLineTypes::TYPE_GOOD) { throw new LogicException(sprintf( "Expected document line with type '%s'.", Model\DocumentLineTypes::TYPE_GOOD )); } if (null === $item = $line->getSaleItem()) { throw new LogicException("Document can't be recalculated."); } $result = $this->calculator->calculateSaleItem($item, $line->getQuantity()); $this->syncLineWithResult($line, $result); if ($item->isPrivate()) { return null; } return $result; }
php
{ "resource": "" }
q248210
DocumentCalculator.calculateDiscountLine
validation
protected function calculateDiscountLine(Model\DocumentLineInterface $line, Amount $gross, Amount $final) { if ($line->getType() !== Model\DocumentLineTypes::TYPE_DISCOUNT) { throw new LogicException(sprintf( "Expected document line with type '%s'.", Model\DocumentLineTypes::TYPE_DISCOUNT )); } /** @var Common\SaleAdjustmentInterface $adjustment */ if (null === $adjustment = $line->getSaleAdjustment()) { throw new LogicException("Document can't be recalculated."); } $result = $this->calculator->calculateSaleDiscount($adjustment, $gross, $final); $this->syncLineWithResult($line, $result); }
php
{ "resource": "" }
q248211
DocumentCalculator.calculateShipmentLine
validation
protected function calculateShipmentLine(Model\DocumentLineInterface $line, Amount $final): Amount { if ($line->getType() !== Model\DocumentLineTypes::TYPE_SHIPMENT) { throw new LogicException(sprintf( "Expected document line with type '%s'.", Model\DocumentLineTypes::TYPE_SHIPMENT )); } $sale = $line->getDocument()->getSale(); $result = $this->calculator->calculateSaleShipment($sale, $final); if (null === $result) { throw new LogicException("Unexpected document shipment line."); } $this->syncLineWithResult($line, $result); return $result; }
php
{ "resource": "" }
q248212
DocumentCalculator.syncLineWithResult
validation
protected function syncLineWithResult(Model\DocumentLineInterface $line, Amount $result) { // TODO Currency conversions // Unit if ($line->getUnit() !== $result->getUnit()) { $line->setUnit($result->getUnit()); $this->changed = true; } // Gross if ($line->getGross() !== $result->getGross()) { $line->setGross($result->getGross()); $this->changed = true; } // Discount if ($line->getDiscount() !== $result->getDiscount()) { $line->setDiscount($result->getDiscount()); $this->changed = true; } // Discount rates $discountRates = []; if (!empty($adjustments = $result->getDiscountAdjustments())) { foreach ($adjustments as $adjustment) { $discountRates[] = $adjustment->getRate(); } } if ($discountRates !== $line->getDiscountRates()) { $line->setDiscountRates($discountRates); $this->changed = true; } // Base if ($line->getBase() !== $result->getBase()) { $line->setBase($result->getBase()); $this->changed = true; } // Tax if ($line->getTax() !== $result->getTax()) { $line->setTax($result->getTax()); $this->changed = true; } // Tax rates $taxRates = []; if (!empty($adjustments = $result->getTaxAdjustments())) { foreach ($adjustments as $adjustment) { $taxRates[] = $adjustment->getRate(); } } if ($taxRates !== $line->getTaxRates()) { $line->setTaxRates($taxRates); $this->changed = true; } // Total if ($line->getTotal() !== $result->getTotal()) { $line->setTotal($result->getTotal()); $this->changed = true; } }
php
{ "resource": "" }
q248213
AbstractFixture.buildEntity
validation
private function buildEntity(ClassMetadata $metadata, $data) { $class = $metadata->getName(); $entity = new $class; foreach ($data as $propertyPath => $value) { // Field if ($metadata->hasField($propertyPath)) { $builtValue = $this->buildFieldValue($metadata, $propertyPath, $value); // Association } elseif ($metadata->hasAssociation($propertyPath)) { $builtValue = $this->buildAssociationValue($metadata, $propertyPath, $value); } else { throw new \Exception("Unexpected property path '$propertyPath' for class '$class'."); } $this->accessor->setValue($entity, $propertyPath, $builtValue); } return $entity; }
php
{ "resource": "" }
q248214
AbstractFixture.buildFieldValue
validation
private function buildFieldValue(ClassMetadata $metadata, $propertyPath, $value) { $type = $metadata->getTypeOfField($propertyPath); switch ($type) { case 'smallint': case 'integer': case 'bigint': if (!is_int($value)) { throw new \Exception('Expected integer.'); } return intval($value); case 'boolean': if (!is_bool($value)) { throw new \Exception('Expected boolean.'); } return (bool)$value; case 'float': case 'double': case 'decimal': if (!is_numeric($value)) { throw new \Exception('Expected float.'); } return floatval($value); case 'datetime': return new \DateTime($value); case 'string': return (string)$value; } throw new \Exception("Unsupported field type '$type' for path '$propertyPath'."); }
php
{ "resource": "" }
q248215
AbstractFixture.buildAssociationValue
validation
private function buildAssociationValue(ClassMetadata $metadata, $propertyPath, $value) { $childMetadata = $this->manager->getClassMetadata( $metadata->getAssociationTargetClass($propertyPath) ); // Single association if ($metadata->isSingleValuedAssociation($propertyPath)) { if (is_string($value) && '#' === substr($value, 0, 1)) { return $this->getReference(substr($value, 1)); } elseif (is_array($value)) { return $this->buildEntity($childMetadata, $value); } throw new \Exception("Unexpected value for single association '$propertyPath'."); // Collection association } elseif ($metadata->isCollectionValuedAssociation($propertyPath)) { if (!is_array($value)) { throw new \Exception('Expected array.'); } $builtValue = []; foreach ($value as $childData) { if (is_string($childData) && '#' === substr($childData, 0, 1)) { array_push($builtValue, $this->getReference(substr($childData, 1))); } elseif (is_array($value)) { array_push($builtValue, $this->buildEntity($childMetadata, $childData)); } else { throw new \Exception("Unexpected value for association '$propertyPath'."); } } return $builtValue; } throw new \Exception("Unexpected association path '$propertyPath'."); }
php
{ "resource": "" }
q248216
AbstractAdjustmentListener.throwIllegalOperationIfAdjustmentIsImmutable
validation
private function throwIllegalOperationIfAdjustmentIsImmutable(ResourceEventInterface $event) { if ($event->getHard()) { return; } $adjustment = $this->getAdjustmentFromEvent($event); // Stop if adjustment is immutable. if ($adjustment->isImmutable()) { throw new IllegalOperationException('ekyna_commerce.sale.message.immutable_element'); } }
php
{ "resource": "" }
q248217
AbstractAdjustmentListener.scheduleSaleContentChangeEvent
validation
protected function scheduleSaleContentChangeEvent(Model\AdjustmentInterface $adjustment) { if ($adjustment instanceof Model\SaleAdjustmentInterface) { if (null === $sale = $this->getSaleFromAdjustment($adjustment)) { // Sale may be scheduled for delete. return; //throw new RuntimeException("Failed to retrieve the sale."); } } elseif ($adjustment instanceof Model\SaleItemAdjustmentInterface) { if (null === $item = $this->getItemFromAdjustment($adjustment)) { // Sale item may be scheduled for delete. return; //throw new RuntimeException("Failed to retrieve the sale item."); } if (null === $sale = $this->getSaleFromItem($item)) { // Sale may be scheduled for delete. return; //throw new RuntimeException("Failed to retrieve the sale."); } } else { throw new InvalidArgumentException("Unexpected adjustment type."); } $this->persistenceHelper->scheduleEvent($this->getSaleChangeEvent(), $sale); }
php
{ "resource": "" }
q248218
AbstractProvider.createAndRegisterGateway
validation
protected function createAndRegisterGateway($platformName, $name, array $config) { $platform = $this->registry->getPlatform($platformName); $gateway = $platform->createGateway($name, $config); if ($gateway instanceof Shipment\AddressResolverAwareInterface) { $gateway->setAddressResolver($this->registry->getAddressResolver()); } if ($gateway instanceof Shipment\WeightCalculatorAwareInterface) { $gateway->setWeightCalculator($this->registry->getWeightCalculator()); } if ($gateway instanceof PersisterAwareInterface) { $gateway->setPersister($this->registry->getPersister()); } $this->gateways[$name] = $gateway; }
php
{ "resource": "" }
q248219
AbstractAttachmentNormalizer.normalizeAttachment
validation
protected function normalizeAttachment(AttachmentInterface $attachment) { $formatter = $this->getFormatter(); return [ 'id' => $attachment->getId(), 'title' => $attachment->getTitle(), 'type' => $attachment->getType(), 'size' => $attachment->getSize(), 'internal' => $attachment->isInternal(), 'file' => pathinfo($attachment->getPath(), PATHINFO_BASENAME), 'created_at' => ($date = $attachment->getCreatedAt()) ? $date->format('Y-m-d H:i:s') : null, 'f_created_at' => ($date = $attachment->getCreatedAt()) ? $formatter->dateTime($date) : null, 'updated_at' => ($date = $attachment->getUpdatedAt()) ? $date->format('Y-m-d H:i:s') : null, 'f_updated_at' => ($date = $attachment->getUpdatedAt()) ? $formatter->dateTime($date) : null, ]; }
php
{ "resource": "" }
q248220
Europa.getClient
validation
private function getClient() { if (null !== $this->client) { return $this->client; } try { return $this->client = new \SoapClient(static::ENDPOINT); } catch (\SoapFault $oExcept) { if ($this->debug) { @trigger_error('Failed to connect to the europa web service: ' . $oExcept->getMessage()); } } return $this->client = null; }
php
{ "resource": "" }
q248221
Customer.findOneAddressBy
validation
protected function findOneAddressBy($expression) { if (0 < $this->addresses->count()) { $criteria = Criteria::create() ->where($expression) ->setMaxResults(1); $matches = $this->addresses->matching($criteria); if ($matches->count() == 1) { return $matches->first(); } } return null; }
php
{ "resource": "" }
q248222
Renderer.factory
validation
static public function factory($type='html', array $params=null) { if (!isset($type) || !strcasecmp($type, 'html')) return (new Html\Renderer($params)); throw new \Exception("Unknown Skriv rendering type '$type'."); }
php
{ "resource": "" }
q248223
DataValidationHelper.validate
validation
public function validate($dataOrRequest, array $rules, array $messages = [], array $customAttributes = []) { $errors = $this->validateAndReturnErrors($dataOrRequest, $rules, $messages, $customAttributes); if (!empty($errors)) { $this->throwValidationErrorsResponse($errors); } return $this->extractInputFromRules($dataOrRequest, $rules); }
php
{ "resource": "" }
q248224
DataValidationHelper.validateAndReturnErrors
validation
public function validateAndReturnErrors($dataOrRequest, array $rules, array $messages = [], array $customAttributes = []) { $messages = Set::flatten($messages); if ($dataOrRequest instanceof Request) { $dataOrRequest = $dataOrRequest->all(); } $validator = $this->getValidationFactory()->make($dataOrRequest, $rules, $messages, $customAttributes); if ($validator->fails()) { return $validator->getMessageBag()->toArray(); } return []; }
php
{ "resource": "" }
q248225
DataValidationHelper.extractInputFromRules
validation
protected function extractInputFromRules($data, array $rules) { $keys = collect($rules)->keys()->map(function ($rule) { return explode('.', $rule)[0]; })->unique()->toArray(); if (!($data instanceof Request)) { $data = collect($data); } return $data->only($keys); }
php
{ "resource": "" }
q248226
ContextProvider.createSaleContext
validation
protected function createSaleContext(SaleInterface $sale): ContextInterface { $context = $this->createContext(); if (null !== $group = $sale->getCustomerGroup()) { $context ->setCustomerGroup($group) ->setBusiness($group->isBusiness()); } if (null !== $address = $sale->getInvoiceAddress()) { $context->setInvoiceCountry($address->getCountry()); } $address = $sale->isSameAddress() ? $sale->getInvoiceAddress() : $sale->getDeliveryAddress(); if (null !== $address) { $context->setDeliveryCountry($address->getCountry()); } if (null !== $currency = $sale->getCurrency()) { $context->setCurrency($currency); } if (null !== $mode = $sale->getVatDisplayMode()) { $context->setVatDisplayMode($mode); } if ($sale instanceof OrderInterface && null !== $date = $sale->getCreatedAt()) { $context->setDate($date); } $context->setTaxExempt($sale->isTaxExempt()); if (null !== $customer = $sale->getCustomer()) { $this->fillFromCustomer($context, $customer); } elseif ($this->customerProvider->hasCustomer()) { $this->fillFromCustomer($context, $this->customerProvider->getCustomer()); } $this->finalize($context); $sale->setContext($context); return $context; }
php
{ "resource": "" }
q248227
ContextProvider.createDefaultContext
validation
protected function createDefaultContext(): ContextInterface { $context = $this->createContext(); if ($this->customerProvider->hasCustomer()) { $this->fillFromCustomer($context, $this->customerProvider->getCustomer()); } $this->finalize($context); return $context; }
php
{ "resource": "" }
q248228
ContextProvider.fillFromCustomer
validation
protected function fillFromCustomer(ContextInterface $context, CustomerInterface $customer): void { if (null === $context->getCustomerGroup()) { $context->setCustomerGroup($customer->getCustomerGroup()); } if (null === $context->getInvoiceCountry()) { if (null !== $address = $customer->getDefaultInvoiceAddress(true)) { $context->setInvoiceCountry($address->getCountry()); } } if (null === $context->getDeliveryCountry()) { if (null !== $address = $customer->getDefaultDeliveryAddress(true)) { $context->setDeliveryCountry($address->getCountry()); } } /*if (null === $context->getCurrency()) { $context->setCurrency($customer->getCurrency()); } if (null === $context->getLocale()) { $context->setLocale($customer->getLocale()); }*/ }
php
{ "resource": "" }
q248229
ContextProvider.finalize
validation
protected function finalize(ContextInterface $context): ContextInterface { if (null === $context->getCustomerGroup()) { $context->setCustomerGroup($this->customerGroupRepository->findDefault()); } if (null === $context->getInvoiceCountry()) { $context->setInvoiceCountry($this->countryProvider->getCountry()); } if (null === $context->getDeliveryCountry()) { $context->setDeliveryCountry($this->countryProvider->getCountry()); } if (null === $context->getCurrency()) { $context->setCurrency($this->currencyProvider->getCurrency()); } if (null === $context->getLocale()) { $context->setLocale($this->localProvider->getCurrentLocale()); } if (null === $context->getVatDisplayMode()) { if (null !== $mode = $context->getCustomerGroup()->getVatDisplayMode()) { $context->setVatDisplayMode($mode); } else { $context->setVatDisplayMode($this->defaultVatDisplayMode); } } $this->eventDispatcher->dispatch(ContextEvents::BUILD, new ContextEvent($context)); return $context; }
php
{ "resource": "" }
q248230
ArrayCurrencyConverter.addRate
validation
private function addRate($pair, $rate) { if (!preg_match('~^[A-Z]{3}/[A-Z]{3}$~', $pair)) { throw new InvalidArgumentException("Unexpected currency pair '$pair'."); } if (!(is_float($rate) && 0 < $rate)) { throw new InvalidArgumentException("Unexpected rate '$rate'."); } $this->rates[$pair] = $rate; return $this; }
php
{ "resource": "" }
q248231
CmfConfig.transApiDoc
validation
static public function transApiDoc(string $translationPath, array $parameters = [], $locale = null) { if (static::class === self::class) { // redirect CmfConfig::transApiDoc() calls to primary config class return self::getPrimary()->transApiDoc($translationPath, $parameters, $locale); } else { $translationPath = 'api_docs.' . ltrim($translationPath, '.'); return static::transCustom($translationPath, $parameters, $locale); } }
php
{ "resource": "" }
q248232
CmfConfig.getLocaleWithSuffix
validation
static public function getLocaleWithSuffix($separator = '_', $lowercased = false): ?string { $locale = preg_split('%[-_]%', strtolower(app()->getLocale())); if (count($locale) === 2) { return $locale[0] . $separator . ($lowercased ? $locale[1] : strtoupper($locale[1])); } else { $localeSuffix = isset(static::$localeSuffixMap[$locale[0]]) ? static::$localeSuffixMap[$locale[0]] : $locale[0]; return $locale[0] . $separator . ($lowercased ? $localeSuffix : strtoupper($localeSuffix)); } }
php
{ "resource": "" }
q248233
CmfConfig.getCacheKeyForOptimizedUiTemplatesBasedOnUserId
validation
static protected function getCacheKeyForOptimizedUiTemplatesBasedOnUserId($group): string { if (static::getAuthModule()->getAccessPolicyClassName() === CmfAccessPolicy::class) { $userId = 'any'; } else { $user = static::getUser(); $userId = $user ? $user->getAuthIdentifier() : 'not_authenticated'; } return static::url_prefix() . '_templates_' . static::getShortLocale() . '_' . $group . '_user_' . $userId; }
php
{ "resource": "" }
q248234
CmfConfig.getCacheKeyForOptimizedUiTemplatesBasedOnUserRole
validation
static protected function getCacheKeyForOptimizedUiTemplatesBasedOnUserRole($group): string { if (static::getAuthModule()->getAccessPolicyClassName() === CmfAccessPolicy::class) { $userId = 'any'; } else { $userId = 'not_authenticated'; $user = static::getUser(); if ($user && $user->existsInDb()) { if ($user::hasColumn('is_superadmin')) { $userId = '__superadmin__'; } else if ($user::hasColumn('role')) { $userId = $user->role; } else { $userId = 'user'; } } } return static::url_prefix() . '_templates_' . static::getShortLocale() . '_' . $group . '_user_' . $userId; }
php
{ "resource": "" }
q248235
UploadableListener.prePersist
validation
public function prePersist(UploadableInterface $uploadable) { if (!$this->enabled) { return; } // TODO Remove (when handled by resource behavior). $uploadable ->setCreatedAt(new \DateTime()) ->setUpdatedAt(new \DateTime()); $this->uploader->prepare($uploadable); }
php
{ "resource": "" }
q248236
Parser.parseApplePriceMatrix
validation
public static function parseApplePriceMatrix($dom, $currency, $directory = null) { if (is_string($dom)) { if (file_exists($dom) && is_file($dom)) { $file = $dom; $dom = new \DOMDocument(); $dom->loadHTMLFile($file); unset ($file); } else { $content = $dom; $dom = new \DOMDocument(); $dom->loadHTML($content); unset ($content); } } if (!$dom instanceof \DOMDocument) { throw new \InvalidArgumentException(sprintf( 'The first argument must be a DOMDocument instance or path to ApplePriceMatrix file, "%s" given.', is_object($dom) ? get_class($dom) : gettype($dom) )); } $currency = strtoupper($currency); // Create XPath for search in DOM $xpath = new \DOMXPath($dom); $tierPrimary = static::parseApplePriceMatrixTier($xpath, 1, $currency); $tierAlternative = static::parseApplePriceMatrixTier($xpath, 2, $currency); $prices = $tierPrimary + $tierAlternative; ksort($prices); if ($directory) { if (!is_writable($directory)) { throw new \RuntimeException(sprintf( 'Could not write prices map to directory "%s". Directory is not writable.', $directory )); } $file = $directory . '/' . $currency . '.php'; file_put_contents($file, '<?php return ' . var_export($prices, 1) . ';'); } return $prices; }
php
{ "resource": "" }
q248237
Parser.parseApplePriceMatrixAll
validation
public static function parseApplePriceMatrixAll($file, $directory = null) { $dom = new \DOMDocument(); $dom->loadHTMLFile($file); $xpath = new \DOMXPath($dom); // Get all currencies $currencies = array(); /** @var \DOMElement[] $currencyElements */ $currencyElements = $xpath->query('//table[1]//tr[2]//td[position() > 1]'); foreach ($currencyElements as $currencyElement) { $currency = trim($currencyElement->textContent); if ('Euro' == $currency) { $currency = 'EUR'; } $currencies[] = $currency; } if (!count($currencies)) { throw new \RuntimeException(sprintf( 'Not found currencies in ApplePriceMatrix in file "%s".', $file )); } $currencies = array_flip($currencies); foreach ($currencies as $currency => $null) { $currencies[$currency] = static::parseApplePriceMatrix($dom, $currency, $directory); } return $currencies; }
php
{ "resource": "" }
q248238
ScaffoldSectionConfig.getViewersForRelations
validation
public function getViewersForRelations() { $ret = []; foreach ($this->getValueViewers() as $key => $viewer) { if ($viewer->isLinkedToDbColumn() && $viewer->hasRelation()) { $ret[$key] = $viewer; } } return $ret; }
php
{ "resource": "" }
q248239
ScaffoldSectionConfig.prepareRelatedRecord
validation
protected function prepareRelatedRecord($relationName, array $relationRecordData, $index = null) { $recordWithBackup = $relationRecordData; $valueViewers = $this->getViewersForRelations(); foreach ($relationRecordData as $columnName => $value) { $viewerName = $relationName . '.' . ($index === null ? '' : $index . '.') . $columnName; if ( array_key_exists($viewerName, $valueViewers) && $valueViewers[$viewerName]->getRelation()->getName() === $relationName ) { $recordWithBackup[$columnName] = $recordWithBackup['__' . $columnName] = $value; $valueViewer = $valueViewers[$viewerName]; if ( is_object($valueViewer) && method_exists($valueViewer, 'convertValue') && ( !method_exists($valueViewer, 'isVisible') || $valueViewer->isVisible() ) ) { $recordWithBackup[$columnName] = $valueViewer->convertValue( $recordWithBackup[$columnName], $relationRecordData ); } } } return $recordWithBackup; }
php
{ "resource": "" }
q248240
ScaffoldSectionConfig.getCssClassesForContainer
validation
public function getCssClassesForContainer() { $colsXl = $this->getWidth() >= 100 ? 12 : ceil(12 * ($this->getWidth() / 100)); $colsXlLeft = floor((12 - $colsXl) / 2); $colsLg = $colsXl >= 10 ? 12 : $colsXl + 2; $colsLgLeft = floor((12 - $colsLg) / 2); return "col-xs-12 col-xl-{$colsXl} col-lg-{$colsLg} col-xl-offset-{$colsXlLeft} col-lg-offset-{$colsLgLeft}"; }
php
{ "resource": "" }
q248241
Route.url
validation
public function url($url = null) { if ($url) $this->url = trim($url); return $this->url; }
php
{ "resource": "" }
q248242
Route.method
validation
public function method($method = null) { if ($method) $this->method = trim($method); return $this->method; }
php
{ "resource": "" }
q248243
Route.action
validation
public function action(Callable $action = null) { if ($action) $this->action = $action; return $this->action; }
php
{ "resource": "" }
q248244
Route.match
validation
public function match($test) { // Generate pattern $isArray = []; $pattern = preg_replace_callback( "~/\{(?<arg>\w+)(?<arr>\[\])?\}(?<num>\?|\+|\*|\{[0-9,]+\})?~", function($matches) use (&$isArray) { $name = $matches["arg"]; $num = $matches["num"] ?? ""; $isArray[$name] = !empty($matches[2]); return "(?<$name>(?:/[^\\s/?]+)$num)"; }, $this->url ); // Pattern error if (!$pattern || empty($pattern)) { // Pattern error error_log("pattern error: found in route with pattern: {$this->url}"); return false; } // Append start, parameters and end $pattern = "^$pattern/?(?:\?.*)?$"; // Match if (preg_match("~$pattern~", $test, $matches)) { foreach ($matches as $name => $val) { // Decode url $val = urldecode($val); // Discard non-associative indexes if (is_int($name)) { if ($name === 0) $this->args[$name] = $val; } else { // Get values as array or as string $val = ltrim($val, "/"); $this->args[$name] = $isArray[$name] ? explode("/", $val) : $val; } } // It's a match! return true; } // Better luck next time! return false; }
php
{ "resource": "" }
q248245
FormatTrait.format
validation
public function format($format) { // Persist format $this->format = $format; // Escape format key letters and escaped characters $format = preg_replace('/([a-zA-Z])/', '%$1', $format); $format = preg_replace('/\\\\%(.)/', '\\\\$1', $format); ///////// // DAY // ///////// $this->format_d($format); $this->formatD($format); $this->format_j($format); $this->format_l($format); $this->formatL($format); $this->formatN($format); $this->formatS($format); $this->format_w($format); $this->format_z($format); ////////// // WEEK // ////////// $this->formatW($format); /////////// // MONTH // /////////// $this->formatF($format); $this->format_m($format); $this->formatM($format); $this->format_n($format); $this->format_t($format); ////////// // YEAR // ////////// $this->formatY($format); $this->format_y($format); ////////// // TIME // ////////// $this->format_a($format); $this->formatA($format); $this->format_g($format); $this->formatG($format); $this->format_h($format); $this->formatH($format); $this->format_i($format); $this->format_s($format); $this->format_u($format); ////////////// // TIMEZONE // ////////////// $this->format_e($format); $this->formatO($format); $this->formatP($format); $this->formatZ($format); /////////// // OTHER // /////////// $this->format_r($format); $this->format_c($format); $this->formatC($format); // Replace escape character and return formatted string return str_replace('\\', '', $format); }
php
{ "resource": "" }
q248246
FormatTrait.format_d
validation
private function format_d(&$str) { if (strstr($str, '%d')) $str = str_replace('%d', sprintf('%02d', $this->day), $str); }
php
{ "resource": "" }
q248247
FormatTrait.formatD
validation
private function formatD(&$str) { if (strstr($str, '%D')) $str = str_replace('%D', $this->dayName(false), $str); }
php
{ "resource": "" }
q248248
FormatTrait.format_j
validation
private function format_j(&$str) { if (strstr($str, '%j')) $str = str_replace('%j', sprintf('%01d', $this->day), $str); }
php
{ "resource": "" }
q248249
FormatTrait.format_l
validation
private function format_l(&$str) { if (strstr($str, '%l')) $str = str_replace('%l', $this->dayName(true), $str); }
php
{ "resource": "" }
q248250
FormatTrait.formatL
validation
private function formatL(&$str) { if (strstr($str, '%L')) $str = str_replace('%L', strtolower($this->dayName(true)), $str); }
php
{ "resource": "" }
q248251
FormatTrait.formatN
validation
private function formatN(&$str) { if (strstr($str, '%N')) { $wdn = $this->weekDayNum(); // Convert 0=Mon 6=Sun to above format $str = str_replace('%N', $wdn == 0 ? 7 : $wdn, $str); } }
php
{ "resource": "" }
q248252
FormatTrait.formatS
validation
private function formatS(&$str) { if (strstr($str, '%S')) $str = str_replace('%S', static::ordinal($this->day), $str); }
php
{ "resource": "" }
q248253
FormatTrait.formatF
validation
private function formatF(&$str) { if (strstr($str, '%F')) $str = str_replace('%F', $this->monthName(true), $str); }
php
{ "resource": "" }
q248254
FormatTrait.format_m
validation
private function format_m(&$str) { if (strstr($str, '%m')) $str = str_replace('%m', sprintf('%02d', $this->month), $str); }
php
{ "resource": "" }
q248255
FormatTrait.format_n
validation
private function format_n(&$str) { if (strstr($str, '%n')) $str = str_replace('%n', sprintf('%01d', $this->month), $str); }
php
{ "resource": "" }
q248256
FormatTrait.format_y
validation
private function format_y(&$str) { if (strstr($str, '%y')) $str = str_replace( '%y', substr($this->year, strlen($this->year) - 2, 2), $str); }
php
{ "resource": "" }
q248257
FormatTrait.format_g
validation
private function format_g(&$str) { if (strstr($str, '%g')) { $h = $this->hour > 12 ? $this->hour - 12 : $this->hour; $str = str_replace('%g', sprintf('%1d', $h), $str); } }
php
{ "resource": "" }
q248258
FormatTrait.formatG
validation
private function formatG(&$str) { if (strstr($str, '%G')) $str = str_replace('%G', sprintf('%1d', $this->hour), $str); }
php
{ "resource": "" }
q248259
FormatTrait.format_h
validation
private function format_h(&$str) { if (strstr($str, '%h')) { $h = $this->hour > 12 ? $this->hour - 12 : $this->hour; $str = str_replace('%h', sprintf('%02d', $h), $str); } }
php
{ "resource": "" }
q248260
FormatTrait.formatH
validation
private function formatH(&$str) { if (strstr($str, '%H')) $str = str_replace('%H', sprintf('%02d', $this->hour), $str); }
php
{ "resource": "" }
q248261
FormatTrait.format_i
validation
private function format_i(&$str) { if (strstr($str, '%i')) $str = str_replace('%i', sprintf('%02d', $this->min), $str); }
php
{ "resource": "" }
q248262
FormatTrait.format_s
validation
private function format_s(&$str) { if (strstr($str, '%s')) $str = str_replace('%s', sprintf('%02d', $this->sec), $str); }
php
{ "resource": "" }
q248263
FormatTrait.formatO
validation
private function formatO(&$str) { if (strstr($str, '%O')) { $o = $this->timezone->offset; $os = $o >= 0 ? '+' : '-'; $oh = sprintf('%02d', abs(intval($o))); $om = sprintf('%02d', abs($o - intval($o)) * 60); $ofs = "{$os}{$oh}{$om}"; $str = str_replace('%O', $ofs, $str); } }
php
{ "resource": "" }
q248264
FormatTrait.formatZ
validation
private function formatZ(&$str) { if (strstr($str, '%Z')) $str = str_replace('%Z', $this->timezone->offset * 3600, $str); }
php
{ "resource": "" }
q248265
FormatterAwareTrait.getFormatter
validation
protected function getFormatter() { if ($this->formatter) { return $this->formatter; } if (!$this->formatterFactory) { throw new RuntimeException("Please call setFormatterFactory() first."); } return $this->formatter = $this->formatterFactory->create(); }
php
{ "resource": "" }
q248266
AuthUtilsComponent.addRememberMeCookie
validation
public function addRememberMeCookie($userId, $options = []) { $options = Hash::merge([ 'expires' => '+14 days', 'httpOnly' => true, 'secure' => false ], $options); $this->Cookie->config($options); $this->Cookie->write('User.id', $userId); }
php
{ "resource": "" }
q248267
AuthUtilsComponent.checkRememberMeCookie
validation
public function checkRememberMeCookie() { if (!$this->loggedIn() && $this->Cookie->read('User.id')) { return $this->Cookie->read('User.id'); } return false; }
php
{ "resource": "" }
q248268
AuthUtilsComponent.autoLogin
validation
public function autoLogin(EntityInterface $user): ?Response { $controller = $this->getController(); $request = $controller->request; $token = $request->getQuery('t'); if (empty($token)) { return null; } $this->Auth->logout(); $tokenData = $user->validateLoginToken($token, $user->getKey(), $user->getSalt()); if (!is_array($tokenData)) { return null; } if (!empty($tokenData['addRememberMeCookie']) && $tokenData['addRememberMeCookie']) { $this->addRememberMeCookie((string)$user->id); } $userData = $user->toArray(); $userData['user'] = $user; $this->Auth->setUser($userData); if (!empty($tokenData['url'])) { return $controller->redirect($tokenData['url']); } return $controller->redirect($this->getConfig('defaultRedirect')); }
php
{ "resource": "" }
q248269
DoctrineBundleMapping.getDefaultImplementations
validation
static function getDefaultImplementations() { return [ Cart\Model\CartInterface::class => Cart\Entity\Cart::class, Cart\Model\CartAddressInterface::class => Cart\Entity\CartAddress::class, Customer\Model\CustomerInterface::class => Customer\Entity\Customer::class, Customer\Model\CustomerGroupInterface::class => Customer\Entity\CustomerGroup::class, Customer\Model\CustomerAddressInterface::class => Customer\Entity\CustomerAddress::class, Order\Model\OrderInterface::class => Order\Entity\Order::class, Order\Model\OrderAddressInterface::class => Order\Entity\OrderAddress::class, Payment\Model\PaymentMethodInterface::class => Payment\Entity\PaymentMethod::class, Payment\Model\PaymentTermInterface::class => Payment\Entity\PaymentTerm::class, Quote\Model\QuoteInterface::class => Quote\Entity\Quote::class, Quote\Model\QuoteAddressInterface::class => Quote\Entity\QuoteAddress::class, Shipment\Model\ShipmentMethodInterface::class => Shipment\Entity\ShipmentMethod::class, Supplier\Model\SupplierInterface::class => Supplier\Entity\Supplier::class, Supplier\Model\SupplierAddressInterface::class => Supplier\Entity\SupplierAddress::class, Supplier\Model\SupplierDeliveryInterface::class => Supplier\Entity\SupplierDelivery::class, Supplier\Model\SupplierOrderInterface::class => Supplier\Entity\SupplierOrder::class, Supplier\Model\SupplierProductInterface::class => Supplier\Entity\SupplierProduct::class, Support\Model\TicketInterface::class => Support\Entity\Ticket::class, Support\Model\TicketMessageInterface::class => Support\Entity\TicketMessage::class, ]; }
php
{ "resource": "" }
q248270
Availability.getMessagesForQuantity
validation
public function getMessagesForQuantity(float $quantity) { $messages = []; if ($quantity < $this->minimumQuantity) { $messages[] = $this->minimumMessage; } elseif (0 < $this->maximumQuantity && $quantity > $this->maximumQuantity) { $messages[] = $this->maximumMessage; } else { if (null !== $this->availableMessage) { $messages[] = $this->availableMessage; } if ($quantity > $this->availableQuantity) { if (null !== $this->resupplyMessage) { $messages[] = $this->resupplyMessage; if ($quantity > $this->availableQuantity + $this->resupplyQuantity) { $messages[] = $this->overflowMessage; } } else { $messages[] = $this->overflowMessage; } } } if (empty($messages)) { $messages[] = $this->overflowMessage; } return $messages; }
php
{ "resource": "" }
q248271
Availability.toArray
validation
public function toArray() { return [ 'o_msg' => $this->overflowMessage, 'min_qty' => $this->minimumQuantity, 'min_msg' => $this->minimumMessage, 'max_qty' => INF === $this->maximumQuantity ? 'INF' : $this->maximumQuantity, 'max_msg' => $this->maximumMessage, 'a_qty' => INF === $this->availableQuantity ? 'INF' : $this->availableQuantity, 'a_msg' => $this->availableMessage, 'r_qty' => $this->resupplyQuantity, 'r_msg' => $this->resupplyMessage, ]; }
php
{ "resource": "" }
q248272
InvoiceLineValidator.findMatchingShipmentItem
validation
private function findMatchingShipmentItem(InvoiceLineInterface $line, ShipmentInterface $shipment) { $saleItem = $line->getSaleItem(); foreach ($shipment->getItems() as $shipmentItem) { if ($saleItem === $shipmentItem->getSaleItem()) { return $shipmentItem; } } return null; }
php
{ "resource": "" }
q248273
Migration.run
validation
public function run($prog = "migrate") { switch (trim($prog)) { case "migrate": return $this->migrate(); case "drop": return $this->drop(); case "reset": return $this->drop() & $this->migrate(); default: error_log("\n\e[1;31m!\e[0m program $prog not applicable\n"); return false; } }
php
{ "resource": "" }
q248274
Migration.lastMigration
validation
protected function lastMigration() { try { // Return last migration in temporal time $migration = Db::query("select * from migrations order by created_at desc limit 1", [], $this->dbName); return $migration[0]; } catch (PDOException $e) { if ($e->getCode() === "42S02") return null; } // Something bad :( return false; }
php
{ "resource": "" }
q248275
Migration.saveMigration
validation
protected function saveMigration(array $tables) { try { $tables = serialize($tables); return Db::query("insert into migrations(host, tables) values(?, ?)", [gethostname(), $tables], $this->dbName, false); } catch (PDOException $e) { error_log($e->getMessage()); return false; } }
php
{ "resource": "" }
q248276
Migration.createMigrationTable
validation
protected function createMigrationTable() { $migrations = new Table("migrations", true); $migrations->string("host")->notNullable()->primaryComposite(); $migrations->timestamp("created_at")->notNullable()->primaryComposite(true); $migrations->blob("tables"); try { return $migrations->create($this->dbName); } catch (PDOException $e) { error_log($e->getMessage()); return false; } }
php
{ "resource": "" }
q248277
Migration.dropMigrationTable
validation
protected function dropMigrationTable() { try { return Db::query("drop table if exists migrations", [], $this->dbName, false); } catch (PDOException $e) { error_log($e->getMessage()); return false; } }
php
{ "resource": "" }
q248278
Migration.computeDependencies
validation
protected static function computeDependencies(array $tables) { /** @todo vulnerable to circular dependencies */ $result = []; while (!empty($tables)) { // Circular dependency check variable $num = count($tables); foreach ($tables as $i => $table) if (!$table->dependent()) { $result[] = $table; // Remove from list // and free dependent tables unset($tables[$i]); foreach ($tables as $t) $t->removeDependency($table->name()); } // If no dependency-free table is found // there is probably a circular dependency // nothing we can do about it if (count($tables) === $num) return false; } return $result; }
php
{ "resource": "" }
q248279
ShipmentSubjectTrait.getShipments
validation
public function getShipments($filter = null) { if (null === $filter) { return $this->shipments; } return $this->shipments->filter(function(ShipmentInterface $shipment) use ($filter) { return $filter xor $shipment->isReturn(); }); }
php
{ "resource": "" }
q248280
ShipmentSubjectTrait.getShippedAt
validation
public function getShippedAt($latest = false) { if (0 == $this->shipments->count()) { return null; } $criteria = Criteria::create(); $criteria ->andWhere(Criteria::expr()->eq('return', false)) ->andWhere(Criteria::expr()->in('state', [ShipmentStates::STATE_READY, ShipmentStates::STATE_SHIPPED])) ->orderBy(['createdAt' => $latest ? Criteria::DESC : Criteria::ASC]); /** @var ArrayCollection $shipments */ $shipments = $this->shipments; $shipments = $shipments->matching($criteria); /** @var ShipmentInterface $shipment */ if (false !== $shipment = $shipments->first()) { return $shipment->getCreatedAt(); } return null; }
php
{ "resource": "" }
q248281
PaymentSubjectStateResolver.hasDifferentCurrencies
validation
protected function hasDifferentCurrencies(PaymentSubjectInterface $subject) { $currency = $subject->getCurrency()->getCode(); foreach ($subject->getPayments() as $payment) { if ($payment->getCurrency()->getCode() !== $currency) { return true; } } return false; }
php
{ "resource": "" }
q248282
PaymentSubjectStateResolver.setState
validation
protected function setState(PaymentSubjectInterface $subject, $state) { if ($state !== $subject->getPaymentState()) { $subject->setPaymentState($state); return true; } return false; }
php
{ "resource": "" }
q248283
CmfUIModule.getScaffoldConfig
validation
public function getScaffoldConfig(string $resourceName): ScaffoldConfigInterface { if (!isset($this->scaffoldConfigs[$resourceName])) { $className = $this->getScaffoldConfigClass($resourceName); $this->scaffoldConfigs[$resourceName] = new $className(); } return $this->scaffoldConfigs[$resourceName]; }
php
{ "resource": "" }
q248284
PropertyOptionsListener.handleSrcTableNames
validation
public function handleSrcTableNames(GetPropertyOptionsEvent $event) { if (($event->getPropertyName() !== 'tag_srctable') || ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')) { return; } $sqlTable = $this->translator->trans( 'tl_metamodel_attribute.tag_table_type.sql-table', [], 'contao_tl_metamodel_attribute' ); $translated = $this->translator->trans( 'tl_metamodel_attribute.tag_table_type.translated', [], 'contao_tl_metamodel_attribute' ); $untranslated = $this->translator->trans( 'tl_metamodel_attribute.tag_table_type.untranslated', [], 'contao_tl_metamodel_attribute' ); $result = $this->getMetaModelTableNames($translated, $untranslated); foreach ($this->connection->getSchemaManager()->listTableNames() as $table) { if (0 !== \strpos($table, 'mm_')) { $result[$sqlTable][$table] = $table; } } if (\is_array($result[$translated])) { \asort($result[$translated]); } if (\is_array($result[$untranslated])) { \asort($result[$untranslated]); } if (\is_array($result[$sqlTable])) { \asort($result[$sqlTable]); } $event->setOptions($result); }
php
{ "resource": "" }
q248285
PropertyOptionsListener.getMetaModelTableNames
validation
private function getMetaModelTableNames($keyTranslated, $keyUntranslated) { $result = []; foreach ($this->factory->collectNames() as $table) { $metaModel = $this->factory->getMetaModel($table); if (null === $metaModel) { continue; } if ($metaModel->isTranslated()) { $result[$keyTranslated][$table] = \sprintf('%s (%s)', $metaModel->get('name'), $table); } else { $result[$keyUntranslated][$table] = \sprintf('%s (%s)', $metaModel->get('name'), $table); } } return $result; }
php
{ "resource": "" }
q248286
PropertyOptionsListener.getColumnNamesFromTable
validation
private function getColumnNamesFromTable($tableName, $typeFilter = null) { if (!$this->connection->getSchemaManager()->tablesExist([$tableName])) { return []; } $result = []; foreach ($this->connection->getSchemaManager()->listTableColumns($tableName) as $column) { if (($typeFilter === null) || \in_array($column->getType()->getName(), $typeFilter, true)) { $result[$column->getName()] = $column->getName(); } } if (!empty($result)) { \asort($result); return $result; } return $result; }
php
{ "resource": "" }
q248287
DocumentBuilder.buildCustomerData
validation
protected function buildCustomerData(Common\SaleInterface $sale) { if (null !== $customer = $sale->getCustomer()) { return [ 'number' => $customer->getNumber(), 'company' => $customer->getCompany(), 'full_name' => trim($customer->getFirstName() . ' ' . $customer->getLastName()), 'email' => $customer->getEmail(), 'phone' => $this->formatPhoneNumber($customer->getPhone()), 'mobile' => $this->formatPhoneNumber($customer->getMobile()), ]; } else { return [ 'number' => null, 'company' => $sale->getCompany(), 'full_name' => trim($sale->getFirstName() . ' ' . $sale->getLastName()), 'email' => $sale->getEmail(), 'phone' => null, 'mobile' => null, ]; } }
php
{ "resource": "" }
q248288
DocumentBuilder.buildAddressData
validation
protected function buildAddressData(Common\AddressInterface $address, string $locale) { // TODO localize $country = Intl::getRegionBundle()->getCountryName($address->getCountry()->getCode(), $locale); $fullName = trim($address->getFirstName() . ' ' . $address->getLastName()); // TODO if empty full customer name $data = [ 'company' => $address->getCompany(), 'full_name' => $fullName, 'street' => $address->getStreet(), 'complement' => $address->getComplement(), 'supplement' => $address->getSupplement(), 'postal_code' => $address->getPostalCode(), 'city' => $address->getCity(), 'country' => $country, 'state' => '', 'phone' => $this->formatPhoneNumber($address->getPhone()), 'mobile' => $this->formatPhoneNumber($address->getMobile()), ]; if ($address instanceof RelayPointInterface) { $data['number'] = $address->getNumber(); } return $data; }
php
{ "resource": "" }
q248289
DocumentBuilder.formatPhoneNumber
validation
protected function formatPhoneNumber(PhoneNumber $number = null) { if ($number) { return $this->phoneNumberUtil->format($number, PhoneNumberFormat::INTERNATIONAL); } return null; }
php
{ "resource": "" }
q248290
DocumentBuilder.buildGoodsLines
validation
protected function buildGoodsLines(Document\DocumentInterface $document) { foreach ($document->getSale()->getItems() as $item) { $this->buildGoodLine($item, $document); } }
php
{ "resource": "" }
q248291
DocumentBuilder.buildDiscountsLines
validation
protected function buildDiscountsLines(Document\DocumentInterface $document) { $sale = $document->getSale(); if (!$sale->hasAdjustments(Common\AdjustmentTypes::TYPE_DISCOUNT)) { return; } $adjustments = $sale->getAdjustments(); foreach ($adjustments as $adjustment) { if ($adjustment->getType() === Common\AdjustmentTypes::TYPE_DISCOUNT) { $this->buildDiscountLine($adjustment, $document); } } }
php
{ "resource": "" }
q248292
PhoneNumberValidator.addViolation
validation
private function addViolation($value, Constraint $constraint) { /** @var \Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber $constraint */ if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->getMessage()) ->setParameter('{{ type }}', $constraint->getType()) ->setParameter('{{ value }}', $this->formatValue($value)) ->setCode(PhoneNumber::INVALID_PHONE_NUMBER_ERROR) ->addViolation(); } else { $this->context->addViolation($constraint->getMessage(), array( '{{ type }}' => $constraint->getType(), '{{ value }}' => $value )); } }
php
{ "resource": "" }
q248293
CmfAuthModule.logoutCurrentUser
validation
public function logoutCurrentUser() { $this->getAuthGuard()->logout(); \Session::remove($this->originalUserFromLoginAsActionSessionKey); \Session::invalidate(); $this->getCmfConfig()->resetLocale(); }
php
{ "resource": "" }
q248294
Iac_Threaded_Mails.get_instance
validation
public static function get_instance() { if ( ! self::$instance instanceof self ) { $new = new self; $new->init(); self::$instance = $new; } return self::$instance; }
php
{ "resource": "" }
q248295
Iac_Threaded_Mails.message_id_header
validation
public function message_id_header( $headers, $iac_options, $item_ID ) { $type = ( 'iac_comment_headers' == current_filter() ) ? 'comment' : 'post'; $item = ( 'post' == $type ) ? get_post( $item_ID ) : get_comment( $item_ID ); $headers[ 'Message-ID' ] = '<' . Iac_Mail_ID::generate_ID( $type, $item ) . '>'; return $headers; }
php
{ "resource": "" }
q248296
TimeZone.offset
validation
public function offset($jd) { // Is DST observed for this timezone? If no, return offset as is if ($this->dst == false) return $this->offset; // Get YMD for provided JD and day of year number (with fractional day) IAU::Jd2cal($jd, 0, $y, $m, $d, $fd); $dayN = static::dayOfYear($y, $m, $d) + $fd; // DST begins at 2:00 a.m. on the second Sunday of March and... IAU::Cal2jd($y, 3, 1, $djm0, $djm); $dayB = static::dayOfYear($y, 2, 1) + 14 - static::weekDayNum($djm0 + $djm) + (2 / 24); // ...ends at 2:00 a.m. on the first Sunday of November IAU::Cal2jd($y, 11, 1, $djm0, $djm); $dayE = static::dayOfYear($y, 11, 1) + 14 - static::weekDayNum($djm0 + $djm) + (2 / 24); // Check if the given JD falls with in the DST range for that year if ($dayN >= $dayB && $dayN < $dayE) return $this->offset + 1; else return $this->offset; }
php
{ "resource": "" }
q248297
TimeZone.dayOfYear
validation
protected static function dayOfYear($y, $m, $d) { $l = ((int)$y % 4 == 0 && (int)$y % 100 != 0) || (int)$y % 400 == 0; $k = $l ? 1 : 2; $n = intval(275 * (int)$m / 9) - $k * intval(((int)$m + 9) / 12) + (int)$d - 30; return (int)$n; }
php
{ "resource": "" }
q248298
AbstractNotification.hasData
validation
public function hasData($key = null) { if (!is_null($key)) { return isset($this->data[$key]); } return !empty($this->data); }
php
{ "resource": "" }
q248299
StockAdjustmentListener.getStockAdjustmentFromEvent
validation
protected function getStockAdjustmentFromEvent(ResourceEventInterface $event) { $stockAdjustment = $event->getResource(); if (!$stockAdjustment instanceof StockAdjustmentInterface) { throw new InvalidArgumentException("Expected instance of " . StockAdjustmentInterface::class); } return $stockAdjustment; }
php
{ "resource": "" }