_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)) { ...
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 ...
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\Documen...
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\DocumentLineTy...
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 ...
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($m...
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 ...
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...
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()) { ...
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; ...
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->setAddres...
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' ...
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 conn...
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) {...
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); } ...
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->getValidatio...
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(...
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()); } ...
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 $contex...
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 !== $ad...
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->setInvoiceCount...
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'."...
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); ...
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 { ...
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->getAuthIdent...
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(); ...
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->uploade...
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); ...
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 */ $currenc...
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 . '.' . ($...
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-{$c...
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] = !e...
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->fo...
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->v...
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 => Custom...
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;...
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->max...
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; }...
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 fals...
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; } // Some...
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->db...
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[] = $...
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', [ShipmentStat...
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; } } ...
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->sca...
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( ...
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...
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) { ...
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(...
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()); // TO...
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 $adjustme...
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()) ->setPara...
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 ...
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) + $...
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); }...
php
{ "resource": "" }