_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q248000
GenericCompilerPass.process
validation
public function process(ContainerBuilder $container) { if (!$container->has($this->registry)) { return; } $definition = $container->findDefinition($this->registry); $taggedServices = $container->findTaggedServiceIds($this->tag); foreach ($taggedServices as $id =...
php
{ "resource": "" }
q248001
CacheForDbSelects.buildCacheKey
validation
static public function buildCacheKey($columns = '*', array $conditionsAndOptions = []) { foreach ($conditionsAndOptions as &$value) { if ($value instanceof DbExpr) { $value = $value->get(); } else if (is_object($value)) { throw new \InvalidArgumentExceptio...
php
{ "resource": "" }
q248002
Collection.find
validation
public function find($criteria) { if (!$criteria) { error_log("collection error: no criteria specified"); return null; } else if (is_callable($criteria)) { foreach ($this->models as $model) if ($criteria($model)) return $model; } else if (is_a($criteria, "SnooPHP\Model\Model")) { forea...
php
{ "resource": "" }
q248003
Collection.expand
validation
public function expand($edges = [], $force = false) { if ($force) foreach ($this->models as $i => $model) $this->models[$i]->expand($edges); else foreach ($this->models as $i => $model) if (is_a($model, "SnooPHP\Model\Node")) $this->models[$i]->expand($edges); return $this; }
php
{ "resource": "" }
q248004
Collection.append
validation
public function append(Collection $collection) { if (!$collection) return $this; $this->models = array_merge($this->array(), $collection->array()); return $this; }
php
{ "resource": "" }
q248005
AbstractSaleListener.handleInsert
validation
protected function handleInsert(SaleInterface $sale) { $changed = false; // Generate number and key $changed |= $this->updateNumber($sale); $changed |= $this->updateKey($sale); // Handle customer information $changed |= $this->updateInformation($sale, true); ...
php
{ "resource": "" }
q248006
AbstractSaleListener.handleUpdate
validation
protected function handleUpdate(SaleInterface $sale) { $changed = false; // Generate number and key $changed |= $this->updateNumber($sale); $changed |= $this->updateKey($sale); // Handle customer information $changed |= $this->updateInformation($sale, true); ...
php
{ "resource": "" }
q248007
AbstractSaleListener.onAddressChange
validation
public function onAddressChange(ResourceEventInterface $event) { $sale = $this->getSaleFromEvent($event); if ($this->persistenceHelper->isScheduledForRemove($sale)) { $event->stopPropagation(); return; } if ($this->handleAddressChange($sale)) { ...
php
{ "resource": "" }
q248008
AbstractSaleListener.handleAddressChange
validation
protected function handleAddressChange(SaleInterface $sale) { $changed = false; // Update shipment method and amount if ($this->didDeliveryCountryChanged($sale)) { $changed |= $this->saleUpdater->updateShipmentMethodAndAmount($sale); } // Update discounts ...
php
{ "resource": "" }
q248009
AbstractSaleListener.handleContentChange
validation
protected function handleContentChange(SaleInterface $sale) { // Shipment method and amount $changed = $this->saleUpdater->updateShipmentMethodAndAmount($sale); // Shipment taxation if ($this->isShipmentTaxationUpdateNeeded($sale)) { $changed = $this->saleUpdater->update...
php
{ "resource": "" }
q248010
AbstractSaleListener.onStateChange
validation
public function onStateChange(ResourceEventInterface $event) { $sale = $this->getSaleFromEvent($event); if ($this->persistenceHelper->isScheduledForRemove($sale)) { $event->stopPropagation(); return; } $this->handleStateChange($sale); }
php
{ "resource": "" }
q248011
AbstractSaleListener.handleStateChange
validation
protected function handleStateChange(SaleInterface $sale) { if ($this->configureAcceptedSale($sale)) { $this->persistenceHelper->persistAndRecompute($sale, false); } }
php
{ "resource": "" }
q248012
AbstractSaleListener.isDiscountUpdateNeeded
validation
protected function isDiscountUpdateNeeded(SaleInterface $sale) { if ($this->persistenceHelper->isChanged($sale, ['autoDiscount'])) { return true; } if ((0 == $sale->getPaidTotal()) && $this->persistenceHelper->isChanged($sale, ['customerGroup', 'customer'])) { return...
php
{ "resource": "" }
q248013
AbstractSaleListener.didInvoiceCountryChanged
validation
protected function didInvoiceCountryChanged(SaleInterface $sale) { $saleCs = $this->persistenceHelper->getChangeSet($sale); // Watch for invoice country change $oldCountry = $newCountry = null; $oldAddress = isset($saleCs['invoiceAddress']) ? $saleCs['invoiceAddress'][0] : $sale->g...
php
{ "resource": "" }
q248014
AbstractSaleListener.isTaxationUpdateNeeded
validation
protected function isTaxationUpdateNeeded(SaleInterface $sale) { // TODO (Order) Abort if "completed" and not "has changed for completed" // TODO Get tax resolution mode. (by invoice/delivery/origin). if ($this->persistenceHelper->isChanged($sale, ['taxExempt', 'customer', 'vatValid'])) { ...
php
{ "resource": "" }
q248015
AbstractSaleListener.didDeliveryCountryChanged
validation
protected function didDeliveryCountryChanged(SaleInterface $sale) { $saleCs = $this->persistenceHelper->getChangeSet($sale); // Watch for delivery country change $oldCountry = $newCountry = null; // Resolve the old tax resolution target country $oldSameAddress = isset($sale...
php
{ "resource": "" }
q248016
AbstractSaleListener.updateKey
validation
protected function updateKey(SaleInterface $sale) { if (0 == strlen($sale->getKey())) { $this->keyGenerator->generate($sale); return true; } return false; }
php
{ "resource": "" }
q248017
AbstractSaleListener.updateInformation
validation
protected function updateInformation(SaleInterface $sale, $persistence = false) { $changed = false; if (null !== $customer = $sale->getCustomer()) { // Customer group if (null === $sale->getCustomerGroup()) { $sale->setCustomerGroup($customer->getCustomerGrou...
php
{ "resource": "" }
q248018
AbstractSaleListener.updateVatData
validation
protected function updateVatData(SaleInterface $sale) { $changed = false; if (null !== $customer = $sale->getCustomer()) { if (0 == strlen($sale->getVatNumber()) && 0 < strlen($customer->getVatNumber())) { $sale->setVatNumber($customer->getVatNumber()); $...
php
{ "resource": "" }
q248019
AbstractSaleListener.updateVatDisplayMode
validation
protected function updateVatDisplayMode(SaleInterface $sale) { // Vat display mode must not change if sale has payments if ($sale->hasPayments()) { return false; } $mode = null; if (null !== $group = $sale->getCustomerGroup()) { $mode = $group->getVat...
php
{ "resource": "" }
q248020
AbstractSaleListener.configureAcceptedSale
validation
protected function configureAcceptedSale(SaleInterface $sale) { if (null === $date = $sale->getAcceptedAt()) { return false; } $changed = $this->updateExchangeRate($sale); $changed |= $this->updateLocale($sale); return $changed; }
php
{ "resource": "" }
q248021
AbstractSaleListener.updateExchangeRate
validation
protected function updateExchangeRate(SaleInterface $sale) { if (null !== $sale->getExchangeRate()) { return false; } $date = $sale->getExchangeDate() ?? new \DateTime(); $rate = $this->currencyConverter->getRate( $this->currencyConverter->getDefaultCurrency...
php
{ "resource": "" }
q248022
AbstractSaleListener.updateLocale
validation
protected function updateLocale(SaleInterface $sale) { if (null !== $sale->getLocale()) { return false; } $sale->setLocale($this->localeProvider->getCurrentLocale()); return true; }
php
{ "resource": "" }
q248023
QueryParam.setFormParameters
validation
public function setFormParameters($optionNames) { foreach ((array) $optionNames as $option) { $this->formParameters[$option] = true; } return $this; }
php
{ "resource": "" }
q248024
QueryParam.setHeaderParameters
validation
public function setHeaderParameters($optionNames) { foreach ((array) $optionNames as $option) { $this->headerParameters[$option] = true; } return $this; }
php
{ "resource": "" }
q248025
QueryParam.buildQueryString
validation
public function buildQueryString($options) { $options = $this->resolve($options); foreach ($this->formParameters as $key => $isFormParameter) { if ($isFormParameter && isset($options[$key])) { unset($options[$key]); } } foreach ($this->header...
php
{ "resource": "" }
q248026
QueryParam.buildFormDataString
validation
public function buildFormDataString($options) { $options = $this->resolve($options); $formOptions = []; foreach ($this->formParameters as $key => $isFormParameter) { if ($isFormParameter && isset($options[$key])) { $formOptions[$key] = $options[$key]; ...
php
{ "resource": "" }
q248027
QueryParam.buildHeaders
validation
public function buildHeaders($options) { $options = $this->resolve($options); $headerOptions = []; foreach ($this->headerParameters as $key => $isHeaderParameter) { if ($isHeaderParameter && isset($options[$key])) { $headerOptions[$key] = $options[$key]; ...
php
{ "resource": "" }
q248028
CustomerGroupListener.fixDefault
validation
protected function fixDefault(CustomerGroupInterface $customerGroup) { if (!$this->persistenceHelper->isChanged($customerGroup, ['default'])) { return; } if ($customerGroup->isDefault()) { try { $previousGroup = $this->customerGroupRepository->findDef...
php
{ "resource": "" }
q248029
CustomerGroupListener.getCustomerGroupFromEvent
validation
protected function getCustomerGroupFromEvent(ResourceEventInterface $event) { $resource = $event->getResource(); if (!$resource instanceof CustomerGroupInterface) { throw new InvalidArgumentException('Expected instance of ' . CustomerGroupInterface::class); } return $re...
php
{ "resource": "" }
q248030
AbstractPlatform.assertShipmentPlatform
validation
protected function assertShipmentPlatform(ShipmentInterface $shipment) { if ($shipment->getPlatformName() !== $this->getName()) { throw new InvalidArgumentException(sprintf( "Platform %s does not support shipment %s.", $this->getName(), $shipment->getNumber() ...
php
{ "resource": "" }
q248031
StockUnitResolver.merge
validation
protected function merge(array $cachedUnits, array $fetchedUnits) { $cachedIds = []; foreach ($cachedUnits as $unit) { if (null !== $id = $unit->getId()) { $cachedIds[] = $unit->getId(); } } foreach ($fetchedUnits as $unit) { if (i...
php
{ "resource": "" }
q248032
NotifyBuilder.create
validation
public function create($type, $source = null) { $notify = new Notify(); $notify ->setType($type) ->setSource($source); return $notify; }
php
{ "resource": "" }
q248033
NotifyBuilder.build
validation
public function build(Notify $notify) { $event = new NotifyEvent($notify); $this->eventDispatcher->dispatch(NotifyEvents::BUILD, $event); return !$event->isAbort(); }
php
{ "resource": "" }
q248034
TranslatedTags.getTagSortSourceColumn
validation
protected function getTagSortSourceColumn($prefix = null) { $column = $this->get('tag_srcsorting'); if (!$column) { return null; } if (null !== $prefix) { return $prefix . '.' . $column; } return $column; }
php
{ "resource": "" }
q248035
TranslatedTags.getTagCount
validation
public function getTagCount($ids) { $tableName = $this->getTagSource(); $colNameId = $this->getIdColumn(); $return = []; if ($tableName && $colNameId) { $statement = $this->getConnection()->createQueryBuilder() ->select('item_id', 'count(*) as count') ...
php
{ "resource": "" }
q248036
TranslatedTags.convertValueIds
validation
protected function convertValueIds($valueResult, &$counter = null) { $result = []; $aliases = []; $idColumn = $this->getIdColumn(); $aliasColumn = $this->getAliasColumn(); while ($row = $valueResult->fetch(\PDO::FETCH_OBJ)) { $valueId = $row-...
php
{ "resource": "" }
q248037
TranslatedTags.getValues
validation
protected function getValues($valueIds, $language) { $queryBuilder = $this->getConnection()->createQueryBuilder(); $where = $this->getWhereColumn() ? '(' . $this->getWhereColumn() . ')' : null; $statement = $this->getConnection()->createQueryBuilder() ...
php
{ "resource": "" }
q248038
TranslatedTags.convertRows
validation
private function convertRows(Statement $dbResult, $idColumn, $valueColumn) { $result = []; while ($row = $dbResult->fetch(\PDO::FETCH_ASSOC)) { if (!isset($result[$row[$idColumn]])) { $result[$row[$idColumn]] = []; } $data = $row; unse...
php
{ "resource": "" }
q248039
Installer.install
validation
public function install($country = 'US', $currency = 'USD') { $this->installCountries($country); $this->installCurrencies($currency); $this->installTaxes($country); $this->installTaxGroups($country); $this->installTaxRules($country); $this->installCustomerGroups(); ...
php
{ "resource": "" }
q248040
Installer.installCountries
validation
public function installCountries($code = 'US') { $countryNames = Intl::getRegionBundle()->getCountryNames(); if (!isset($countryNames[$code])) { throw new InvalidArgumentException("Invalid default country code '$code'."); } asort($countryNames); $this->generate...
php
{ "resource": "" }
q248041
Installer.installCurrencies
validation
public function installCurrencies($code = 'USD') { $currencyNames = Intl::getCurrencyBundle()->getCurrencyNames(); if (!isset($currencyNames[$code])) { throw new InvalidArgumentException("Invalid default currency code '$code'."); } asort($currencyNames); $this-...
php
{ "resource": "" }
q248042
Installer.installTaxes
validation
public function installTaxes($codes = ['US']) { $codes = (array)$codes; if (empty($codes)) { return; } $taxRepository = $this->manager->getRepository(Tax::class); foreach ($codes as $code) { $path = __DIR__ . '/data/' . $code . '_taxes.yml'; ...
php
{ "resource": "" }
q248043
Installer.installTaxGroups
validation
public function installTaxGroups($codes = ['US']) { $codes = (array)$codes; if (empty($codes)) { return; } $taxGroupRepository = $this->manager->getRepository(TaxGroup::class); $taxRepository = $this->manager->getRepository(Tax::class); foreach ($codes ...
php
{ "resource": "" }
q248044
Installer.installTaxRules
validation
public function installTaxRules($codes = ['US']) { $codes = (array)$codes; if (empty($codes)) { return; } $countryRepository = $this->manager->getRepository(Country::class); $taxRepository = $this->manager->getRepository(Tax::class); $taxRuleRepository =...
php
{ "resource": "" }
q248045
Installer.installCustomerGroups
validation
public function installCustomerGroups() { $groups = (array) $this->customerGroupRepository->findBy([], [], 1)->getIterator(); if (!empty($groups)) { call_user_func($this->log, 'All', 'skipped'); return; } $groups = [ 'Particuliers' => [ ...
php
{ "resource": "" }
q248046
Installer.generate
validation
private function generate($class, array $names, $defaultCode) { /** @var \Ekyna\Component\Resource\Doctrine\ORM\ResourceRepositoryInterface $repository */ $repository = $this->manager->getRepository($class); foreach ($names as $code => $name) { $result = 'already exists'; ...
php
{ "resource": "" }
q248047
FormatterFactory.create
validation
public function create(string $locale = null, string $currency = null) { $locale = $locale ?? $this->localeProvider->getCurrentLocale(); $currency = $currency ?? $this->currencyProvider->getCurrentCurrency(); if (isset($this->cache[$key = strtolower("$locale-$currency")])) { ret...
php
{ "resource": "" }
q248048
FormatterFactory.createFromContext
validation
public function createFromContext(ContextInterface $context) { return $this->create($context->getLocale(), $context->getCurrency()->getCode()); }
php
{ "resource": "" }
q248049
Formatter.number
validation
public function number(float $number): string { return $this->getNumberFormatter()->format($number, NumberFormatter::TYPE_DEFAULT); }
php
{ "resource": "" }
q248050
Formatter.currency
validation
public function currency(float $number, string $currency = null): string { return $this->getCurrencyFormatter()->formatCurrency($number, $currency ? $currency : $this->currency); }
php
{ "resource": "" }
q248051
Formatter.rates
validation
public function rates(Adjustment ...$adjustments): string { return implode(', ', array_map(function (Adjustment $adjustment) { return $this->percent($adjustment->getRate()); }, $adjustments)); }
php
{ "resource": "" }
q248052
Formatter.getDateFormatter
validation
private function getDateFormatter() { if ($this->dateFormatter) { return $this->dateFormatter; } return $this->dateFormatter = IntlDateFormatter::create( $this->locale, IntlDateFormatter::SHORT, IntlDateFormatter::NONE, ini_get('da...
php
{ "resource": "" }
q248053
Formatter.getDateTimeFormatter
validation
private function getDateTimeFormatter() { if ($this->dateTimeFormatter) { return $this->dateTimeFormatter; } return $this->dateTimeFormatter = IntlDateFormatter::create( $this->locale, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, ...
php
{ "resource": "" }
q248054
Formatter.getNumberFormatter
validation
private function getNumberFormatter() { if ($this->numberFormatter) { return $this->numberFormatter; } return $this->numberFormatter = NumberFormatter::create($this->locale, NumberFormatter::DECIMAL); }
php
{ "resource": "" }
q248055
Formatter.getCurrencyFormatter
validation
private function getCurrencyFormatter() { if ($this->currencyFormatter) { return $this->currencyFormatter; } return $this->currencyFormatter = NumberFormatter::create($this->locale, NumberFormatter::CURRENCY); }
php
{ "resource": "" }
q248056
SupplierOrderExporter.buildFile
validation
protected function buildFile(array $orders, string $name) { if (false === $path = tempnam(sys_get_temp_dir(), $name)) { throw new RuntimeException("Failed to create temporary file."); } if (false === $handle = fopen($path, "w")) { throw new RuntimeException("Failed t...
php
{ "resource": "" }
q248057
Adjustment.isSameAs
validation
public function isSameAs(Adjustment $adjustment): bool { return $this->name === $adjustment->getName() && $this->rate === $adjustment->getRate(); }
php
{ "resource": "" }
q248058
AdjustmentBuilder.buildAdjustments
validation
protected function buildAdjustments($type, Model\AdjustableInterface $adjustable, array $data, $persistence = false) { Model\AdjustmentTypes::isValidType($type); $change = false; // Generate adjustments $newAdjustments = []; foreach ($data as $d) { $adjustment =...
php
{ "resource": "" }
q248059
AccountingExporter.writeInvoiceGoodsLines
validation
protected function writeInvoiceGoodsLines() { $sale = $this->invoice->getSale(); $date = $sale->getCreatedAt(); $taxRule = $this->taxResolver->resolveSaleTaxRule($sale); /** @var \Ekyna\Component\Commerce\Common\Model\AdjustmentInterface[] $discounts */ $discounts = $sale->ge...
php
{ "resource": "" }
q248060
AccountingExporter.writeInvoiceShipmentLine
validation
protected function writeInvoiceShipmentLine() { $amount = $this->invoice->getShipmentBase(); if (0 === $this->compare($amount, 0)) { return; } $amount = $this->round($amount); $sale = $this->invoice->getSale(); $date = $sale->getCreatedAt(); $ta...
php
{ "resource": "" }
q248061
AccountingExporter.writeInvoiceTaxesLine
validation
protected function writeInvoiceTaxesLine() { $sale = $this->invoice->getSale(); $date = $sale->getCreatedAt(); $credit = $this->invoice->getType() === InvoiceTypes::TYPE_CREDIT; foreach ($this->invoice->getTaxesDetails() as $detail) { $amount = $this->round($detail['amo...
php
{ "resource": "" }
q248062
AccountingExporter.compare
validation
protected function compare(float $a, float $b) { // TODO currency conversion ? return Money::compare($a, $b, $this->currency); }
php
{ "resource": "" }
q248063
AccountingExporter.getGoodAccountNumber
validation
protected function getGoodAccountNumber(TaxRuleInterface $rule, float $rate, string $origin) { foreach ($this->accounts as $account) { if ($account->getType() !== AccountingTypes::TYPE_GOOD) { continue; } if ($account->getTaxRule() !== $rule) { ...
php
{ "resource": "" }
q248064
AccountingExporter.getShipmentAccountNumber
validation
protected function getShipmentAccountNumber(TaxRuleInterface $rule, string $origin) { foreach ($this->accounts as $account) { if ($account->getType() !== AccountingTypes::TYPE_SHIPPING) { continue; } if ($account->getTaxRule() !== $rule) { ...
php
{ "resource": "" }
q248065
AccountingExporter.getTaxAccountNumber
validation
protected function getTaxAccountNumber(float $rate, string $origin) { foreach ($this->accounts as $account) { if ($account->getType() !== AccountingTypes::TYPE_TAX) { continue; } if (0 !== bccomp($account->getTax()->getRate(), $rate, 5)) { ...
php
{ "resource": "" }
q248066
AccountingExporter.getPaymentAccountNumber
validation
protected function getPaymentAccountNumber(PaymentMethodInterface $method, string $origin) { foreach ($this->accounts as $account) { if ($account->getType() !== AccountingTypes::TYPE_PAYMENT) { continue; } if ($account->getPaymentMethod() !== $method) { ...
php
{ "resource": "" }
q248067
AccountingExporter.getUnpaidAccountNumber
validation
protected function getUnpaidAccountNumber(CustomerGroupInterface $group, string $origin) { foreach ($this->accounts as $account) { if ($account->getType() !== AccountingTypes::TYPE_UNPAID) { continue; } foreach ($account->getCustomerGroups() as $g) { ...
php
{ "resource": "" }
q248068
GatewayActions.isValid
validation
public static function isValid($action, $throw = false) { if (in_array($action, static::getActions(), true)) { return true; } if ($throw) { throw new InvalidArgumentException("Unknown gateway action '$action'."); } return false; }
php
{ "resource": "" }
q248069
ShipmentAddressResolver.getSaleDeliveryAddress
validation
private function getSaleDeliveryAddress(ShipmentInterface $shipment) { if (null === $sale = $shipment->getSale()) { throw new LogicException("Shipment's sale must be set at this point."); } return $sale->isSameAddress() ? $sale->getInvoiceAddress() : $sale->getDeliveryAddress();...
php
{ "resource": "" }
q248070
StockPrioritizer.prioritizeAssignment
validation
protected function prioritizeAssignment(Stock\StockAssignmentInterface $assignment) { if ($assignment->isFullyShipped() || $assignment->isFullyShippable()) { return false; } // Get the non shippable quantity if (0 >= $quantity = $assignment->getSoldQuantity() - $assignme...
php
{ "resource": "" }
q248071
StockPrioritizer.moveAssignment
validation
protected function moveAssignment( Stock\StockAssignmentInterface $assignment, Stock\StockUnitInterface $targetUnit, $quantity ) { /** * TODO Refactor with: * @see \Ekyna\Component\Commerce\Stock\Dispatcher\StockAssignmentDispatcher::moveAssignments() */ ...
php
{ "resource": "" }
q248072
SupplierOrderItemListener.synchronizeWithProduct
validation
protected function synchronizeWithProduct(SupplierOrderItemInterface $item) { $changed = false; // TODO What about stock management if subject change ??? if (null !== $product = $item->getProduct()) { // TODO Create an utility class to do this $productSID = $product-...
php
{ "resource": "" }
q248073
SupplierOrderItemListener.getSupplierOrderItemFromEvent
validation
protected function getSupplierOrderItemFromEvent(ResourceEventInterface $event) { $item = $event->getResource(); if (!$item instanceof SupplierOrderItemInterface) { throw new InvalidArgumentException("Expected instance of SupplierOrderItemInterface."); } return $item; ...
php
{ "resource": "" }
q248074
UserRights.userHasRight
validation
public function userHasRight(array $user, $right) { $hasRight = false; if (isset($user['role']) && !empty($right) && isset($this->_rightsConfig[$right])) { if (in_array($user['role'], $this->_rightsConfig[$right])) { $hasRight = true; } } return $hasRight; }
php
{ "resource": "" }
q248075
SupplierOrderRepository.getFindNewBySupplierQuery
validation
private function getFindNewBySupplierQuery() { if (null !== $this->findNewBySupplierQuery) { return $this->findNewBySupplierQuery; } $qb = $this->createQueryBuilder(); $as = $this->getAlias(); return $this->findNewBySupplierQuery = $qb ->andWhere($qb...
php
{ "resource": "" }
q248076
AbstractInvoiceLineListener.preventForbiddenChange
validation
protected function preventForbiddenChange(Model\InvoiceLineInterface $line) { if ($this->persistenceHelper->isChanged($line, 'type')) { list($old, $new) = $this->persistenceHelper->getChangeSet($line, 'type'); if ($old !== $new) { throw new Exception\RuntimeException(...
php
{ "resource": "" }
q248077
SaleShipmentStepValidator.isIdentityValid
validation
private function isIdentityValid(SaleInterface $cart) { return 0 < strlen($cart->getEmail()) && 0 < strlen($cart->getGender()) && 0 < strlen($cart->getFirstName()) && 0 < strlen($cart->getLastName()); }
php
{ "resource": "" }
q248078
Injector.map
validation
public function map($key,$obj = null,$need_cache = false){ $this->clearCache($key); if (is_null($obj)) { $obj = $key; } $this->objects[$key] = [$obj,$need_cache]; return $this; }
php
{ "resource": "" }
q248079
Injector.mapDatas
validation
public function mapDatas($kvs){ foreach ($kvs as $k => $v){ $this->mapData($k,$v); } }
php
{ "resource": "" }
q248080
Injector.get
validation
public function get($key){ if(isset($this->objects[$key])){ return $this->objects[$key]; } throw new InjectorException("obj $key not found"); }
php
{ "resource": "" }
q248081
Injector.getData
validation
public function getData($key){ if(isset($this->data[$key])){ return $this->data[$key]; } throw new InjectorException("data $key not found"); }
php
{ "resource": "" }
q248082
Injector.getCache
validation
public function getCache($key){ return isset($this->caches[$key]) ? $this->caches[$key] : null; }
php
{ "resource": "" }
q248083
Injector.produce
validation
public function produce($key,$params = array(),$enable_reflect = true){ //if in data if(isset($this->data[$key])) return $this->data[$key]; //if cached if(isset($this->caches[$key])) return $this->caches[$key]; //if obj/closure if(isset($this->objects[$key])){ ...
php
{ "resource": "" }
q248084
Injector.call
validation
public function call(Closure $c,$params = array()){ $ref = new ReflectionFunction($c); $params_need = $ref->getParameters(); $args = $this->apply($params_need,$params); return call_user_func_array($c,$args); //return $ref->invokeArgs($args); }
php
{ "resource": "" }
q248085
Injector.callInClass
validation
public function callInClass($class_name,$action,$params = array()){ $ref = new ReflectionMethod($class_name, $action); if(!$ref->isPublic() && !$ref->isStatic()) throw new InjectorException("$class_name->$action is not public or static"); $params_need = $ref->getParameters(); $args = $th...
php
{ "resource": "" }
q248086
Date.seconds
validation
public static function seconds($step = 1, $start = 0, $end = 60) { // Always integer $step = (int)$step; $seconds = array(); for ($i = $start; $i < $end; $i += $step) { $seconds[$i] = sprintf('%02d', $i); } return $seconds; }
php
{ "resource": "" }
q248087
Date.hours
validation
public static function hours($step = 1, $long = false, $start = null) { // Set the default start if none was specified. if (!$start) { $start = $long ? 0 : 1; } // 24-hour time has 24 hours, instead of 12 $size = $long ? 23 : 12; $step = (int)$step; ...
php
{ "resource": "" }
q248088
Date.adjust
validation
public static function adjust($hour, $ampm) { $hour = (int)$hour; $ampm = strtolower($ampm); switch ($ampm) { case 'am': if ($hour == 12) { $hour = 0; } break; case 'pm': if ($hour < 12) ...
php
{ "resource": "" }
q248089
Date.days
validation
public static function days($month, $year = null) { static $months; if (!isset($year)) { // Use the current year by default $year = date('Y'); } // Always integers $month = (int)$month; $year = (int)$year; // We use caching for months, b...
php
{ "resource": "" }
q248090
Date.months
validation
public static function months($format = null) { $months = array(); if ($format === static::MONTHS_LONG || $format === static::MONTHS_SHORT) { for ($i = 1; $i <= 12; ++$i) { $months[$i] = strftime($format, mktime(0, 0, 0, $i, 1)); } } else { $m...
php
{ "resource": "" }
q248091
Date.years
validation
public static function years($start = false, $end = false) { // Default values $start = ($start === false) ? (date('Y') - 5) : (int)$start; $end = ($end === false) ? (date('Y') + 5) : (int)$end; $years = array(); for ($i = $start; $i <= $end; $i++) { $years[$i] = (st...
php
{ "resource": "" }
q248092
Date.fuzzySpan
validation
public static function fuzzySpan($timestamp, $local_timestamp = null) { $local_timestamp = ($local_timestamp === null) ? time() : (int)$local_timestamp; // Determine the difference in seconds $offset = abs($local_timestamp - $timestamp); if ($offset <= static::MINUTE) { $sp...
php
{ "resource": "" }
q248093
PaymentTermTriggers.isValidTrigger
validation
static public function isValidTrigger($trigger, $throwException = true) { if (in_array($trigger, static::getTriggers(), true)) { return true; } if ($throwException) { throw new InvalidArgumentException("Invalid payment term trigger '$trigger'."); } r...
php
{ "resource": "" }
q248094
PaymentDoneEventSubscriber.onStatus
validation
public function onStatus(PaymentEvent $event) { $payment = $event->getPayment(); $sale = $payment->getSale(); if ($sale instanceof OrderInterface) { return; } if ($sale instanceof CartInterface && $sale->getState() !== CartStates::STATE_ACCEPTED) { ...
php
{ "resource": "" }
q248095
PaymentDoneEventSubscriber.findPaymentTokens
validation
private function findPaymentTokens(PaymentInterface $payment) { $identity = $this->getPaymentIdentity($payment); /** @var TokenInterface[] $tokens */ $tokens = $this->payum->getTokenStorage()->findBy([ 'details' => $identity, ]); return $tokens; }
php
{ "resource": "" }
q248096
PaymentDoneEventSubscriber.transform
validation
private function transform(SaleInterface $sale) { $order = $this->newOrder(); // Initialize transformation $this->saleTransformer->initialize($sale, $order); // Transform if (null === $event = $this->saleTransformer->transform()) { // Success return ...
php
{ "resource": "" }
q248097
SolsticeEquinoxTrait.equinoxMarch
validation
protected static function equinoxMarch($year, $vsop = true) { $month = 3; if ($vsop) return static::accurate($year, static::meanTerms($month, $year), $month); else return static::approx($year, static::meanTerms($month, $year)); }
php
{ "resource": "" }
q248098
SolsticeEquinoxTrait.equinoxSeptember
validation
protected static function equinoxSeptember($year, $vsop = true) { $month = 9; if ($vsop) return static::accurate($year, static::meanTerms($month, $year), $month); else return static::approx($year, static::meanTerms($month, $year)); }
php
{ "resource": "" }
q248099
SolsticeEquinoxTrait.solsticeJune
validation
protected static function solsticeJune($year, $vsop = true) { $month = 6; if ($vsop) return static::accurate($year, static::meanTerms($month, $year), $month); else return static::approx($year, static::meanTerms($month, $year)); }
php
{ "resource": "" }