Applied php-cs-fixer

This commit is contained in:
Franck Allimant
2014-05-17 10:24:22 +02:00
parent f8ccea1899
commit ef142ca077
23 changed files with 76 additions and 88 deletions

View File

@@ -28,8 +28,6 @@ use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\Coupon as CouponModel;
use Thelia\Model\CouponCountry;
use Thelia\Model\CouponCountryQuery;
use Thelia\Model\CouponCustomerCount;
use Thelia\Model\CouponCustomerCountQuery;
use Thelia\Model\CouponModule;
use Thelia\Model\CouponModuleQuery;
use Thelia\Model\CouponQuery;
@@ -309,7 +307,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$couponCountries = CouponCountryQuery::create()->filterByCouponId($couponModel->getId())->find();
/** @var CouponCountry $couponCountry */
foreach($couponCountries as $couponCountry) {
foreach ($couponCountries as $couponCountry) {
$occ = new OrderCouponCountry();
$occ
@@ -322,7 +320,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$couponModules = CouponModuleQuery::create()->filterByCouponId($couponModel->getId())->find();
/** @var CouponModule $couponModule */
foreach($couponModules as $couponModule) {
foreach ($couponModules as $couponModule) {
$ocm = new OrderCouponModule();
$ocm
@@ -334,8 +332,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
}
$con->commit();
}
catch (\Exception $ex) {
} catch (\Exception $ex) {
$con->rollBack();
throw($ex);

View File

@@ -44,9 +44,9 @@ abstract class AbstractMatchCountries extends ConditionAbstract
parent::__construct($facade);
}
protected abstract function getSummaryLabel($cntryStrList, $i18nOperator);
abstract protected function getSummaryLabel($cntryStrList, $i18nOperator);
protected abstract function getFormLabel();
abstract protected function getFormLabel();
/**
* @inheritdoc
@@ -87,6 +87,7 @@ abstract class AbstractMatchCountries extends ConditionAbstract
// The delivery address should match one of the selected countries.
/* TODO !!!! */
return $this->conditionValidator->variableOpComparison(
$this->facade->getNbArticlesInCart(),
$this->operators[self::COUNTRIES_LIST],
@@ -110,7 +111,7 @@ abstract class AbstractMatchCountries extends ConditionAbstract
if (null !== $cntryList = CountryQuery::create()->findPks($cntryIds)) {
/** @var Category $cntry */
foreach($cntryList as $cntry) {
foreach ($cntryList as $cntry) {
$cntryStrList .= $cntry->getTitle() . ', ';
}
@@ -147,4 +148,4 @@ abstract class AbstractMatchCountries extends ConditionAbstract
]
);
}
}
}

View File

@@ -93,12 +93,12 @@ class CartContainsCategories extends ConditionAbstract
$cartItems = $this->facade->getCart()->getCartItems();
/** @var CartItem $cartItem */
foreach($cartItems as $cartItem) {
foreach ($cartItems as $cartItem) {
$categories = $cartItem->getProduct()->getCategories();
/** @var Category $category */
foreach($categories as $category) {
foreach ($categories as $category) {
$catecoryInCart = $this->conditionValidator->variableOpComparison(
$category->getId(),
$this->operators[self::CATEGORIES_LIST],
@@ -156,7 +156,7 @@ class CartContainsCategories extends ConditionAbstract
if (null !== $catList = CategoryQuery::create()->findPks($catIds)) {
/** @var Category $cat */
foreach($catList as $cat) {
foreach ($catList as $cat) {
$catStrList .= $cat->getTitle() . ', ';
}

View File

@@ -93,13 +93,12 @@ class CartContainsProducts extends ConditionAbstract
$cartItems = $this->facade->getCart()->getCartItems();
/** @var CartItem $cartItem */
foreach($cartItems as $cartItem) {
foreach ($cartItems as $cartItem) {
if ($this->conditionValidator->variableOpComparison(
$cartItem->getProduct()->getId(),
$this->operators[self::PRODUCTS_LIST],
$this->values[self::PRODUCTS_LIST])) {
return true;
}
}
@@ -149,7 +148,7 @@ class CartContainsProducts extends ConditionAbstract
if (null !== $prodList = ProductQuery::create()->findPks($prodIds)) {
/** @var Product $prod */
foreach($prodList as $prod) {
foreach ($prodList as $prod) {
$prodStrList .= $prod->getTitle() . ', ';
}

View File

@@ -66,15 +66,15 @@ abstract class ConditionAbstract implements ConditionInterface
}
/**
* @param array $operatorList the list of comparison operator values, as entered in the condition parameter form
* @param array $operatorList the list of comparison operator values, as entered in the condition parameter form
* @param string $parameterName the name of the parameter to check
*
* @return $this
*
* @throws \Thelia\Exception\InvalidConditionOperatorException if the operator value is not in the allowed value
*/
protected function checkComparisonOperatorValue($operatorList, $parameterName) {
protected function checkComparisonOperatorValue($operatorList, $parameterName)
{
$isOperator1Legit = $this->isOperatorLegit(
$operatorList[$parameterName],
$this->availableOperators[$parameterName]

View File

@@ -139,7 +139,7 @@ class ForSomeCustomers extends ConditionAbstract
if (null !== $custList = CustomerQuery::create()->findPks($custIds)) {
/** @var Customer $cust */
foreach($custList as $cust) {
foreach ($custList as $cust) {
$custStrList .= $cust->getLastname() . ' ' . $cust->getFirstname() . ' ('.$cust->getRef().'), ';
}

View File

@@ -69,8 +69,8 @@ class MatchBillingCountries extends AbstractMatchCountries
return $toolTip;
}
protected function getSummaryLabel($cntryStrList, $i18nOperator) {
protected function getSummaryLabel($cntryStrList, $i18nOperator)
{
return $this->translator->trans(
'Only if order billing country is %op% <strong>%countries_list%</strong>', [
'%countries_list%' => $cntryStrList,
@@ -79,7 +79,8 @@ class MatchBillingCountries extends AbstractMatchCountries
);
}
protected function getFormLabel() {
protected function getFormLabel()
{
return $this->translator->trans(
'Billing coutry is', [], 'condition'
);

View File

@@ -69,8 +69,8 @@ class MatchDeliveryCountries extends AbstractMatchCountries
return $toolTip;
}
protected function getSummaryLabel($cntryStrList, $i18nOperator) {
protected function getSummaryLabel($cntryStrList, $i18nOperator)
{
return $this->translator->trans(
'Only if order shipping country is %op% <strong>%countries_list%</strong>', [
'%countries_list%' => $cntryStrList,
@@ -79,7 +79,8 @@ class MatchDeliveryCountries extends AbstractMatchCountries
);
}
protected function getFormLabel() {
protected function getFormLabel()
{
return $this->translator->trans(
'Delivery coutry is', [], 'condition'
);

View File

@@ -26,8 +26,8 @@ class MatchForEveryone extends ConditionAbstract
/**
* @inheritdoc
*/
public function __construct(FacadeInterface $facade) {
public function __construct(FacadeInterface $facade)
{
// Define the allowed comparison operators
$this->availableOperators = [];

View File

@@ -14,7 +14,6 @@ namespace Thelia\Condition\Implementation;
use Thelia\Condition\Operators;
use Thelia\Coupon\FacadeInterface;
use Thelia\Exception\InvalidConditionOperatorException;
use Thelia\Exception\InvalidConditionValueException;
/**

View File

@@ -14,11 +14,7 @@ namespace Thelia\Condition\Implementation;
use Thelia\Condition\Operators;
use Thelia\Coupon\FacadeInterface;
use Thelia\Exception\InvalidConditionOperatorException;
use Thelia\Exception\InvalidConditionValueException;
use Thelia\Model\Category;
use Thelia\Model\CategoryImageQuery;
use Thelia\Model\CategoryQuery;
use Thelia\Tools\DateTimeFormat;
/**
@@ -76,8 +72,7 @@ class StartDate extends ConditionAbstract
}
$timestamp = $date->getTimestamp();
}
else {
} else {
$timestamp = $values[self::START_DATE];
}
@@ -147,7 +142,8 @@ class StartDate extends ConditionAbstract
return $toolTip;
}
private function getDateFormat() {
private function getDateFormat()
{
return DateTimeFormat::getInstance($this->facade->getRequest())->getFormat("date");
}
@@ -177,8 +173,7 @@ class StartDate extends ConditionAbstract
$date->setTimestamp($this->values[self::START_DATE]);
$strDate = $date->format($this->getDateFormat());
}
else {
} else {
$strDate = '';
}
@@ -189,4 +184,4 @@ class StartDate extends ConditionAbstract
'currentValue' => $strDate
]);
}
}
}

View File

@@ -157,12 +157,12 @@ class CouponController extends BaseAdminController
$freeShippingForCountries = $freeShippingForModules = [];
/** @var CouponCountry $item */
foreach($coupon->getFreeShippingForCountries() as $item) {
foreach ($coupon->getFreeShippingForCountries() as $item) {
$freeShippingForCountries[] = $item->getCountryId();
}
/** @var CouponModule $item */
foreach($coupon->getFreeShippingForModules() as $item) {
foreach ($coupon->getFreeShippingForModules() as $item) {
$freeShippingForModules[] = $item->getModuleId();
}

View File

@@ -37,9 +37,9 @@ class CouponConsumeEvent extends ActionEvent
/**
* Constructor
*
* @param string $code Coupon code
* @param float $discount Total discount given by this coupon
* @param bool $isValid If Coupon is valid or f Customer meets coupon conditions
* @param string $code Coupon code
* @param float $discount Total discount given by this coupon
* @param bool $isValid If Coupon is valid or f Customer meets coupon conditions
* @param bool $freeShipping true if coupon offers free shipping
*/
public function __construct($code, $discount = null, $isValid = null, $freeShipping = false)
@@ -57,6 +57,7 @@ class CouponConsumeEvent extends ActionEvent
public function setFreeShipping($freeShipping)
{
$this->freeShipping = $freeShipping;
return $this;
}

View File

@@ -134,6 +134,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
public function setPerCustomerUsageCount($perCustomerUsageCount)
{
$this->perCustomerUsageCount = $perCustomerUsageCount;
return $this;
}
@@ -146,12 +147,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
}
/**
* @param array $freeShippingForCountries
* @param array $freeShippingForCountries
* @return $this
*/
public function setFreeShippingForCountries($freeShippingForCountries)
{
$this->freeShippingForCountries = $freeShippingForCountries;
return $this;
}
@@ -164,12 +166,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
}
/**
* @param array $freeShippingForMethods
* @param array $freeShippingForMethods
* @return $this
*/
public function setFreeShippingForMethods($freeShippingForMethods)
{
$this->freeShippingForMethods = $freeShippingForMethods;
return $this;
}

View File

@@ -198,13 +198,13 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
$freeShippingForCountriesIds = [];
/** @var CouponCountry $couponCountry */
foreach($coupon->getFreeShippingForCountries() as $couponCountry) {
foreach ($coupon->getFreeShippingForCountries() as $couponCountry) {
$freeShippingForCountriesIds[] = $couponCountry->getCountryId();
}
$freeShippingForModulesIds = [];
/** @var CouponModule $couponModule */
foreach($coupon->getFreeShippingForModules() as $couponModule) {
foreach ($coupon->getFreeShippingForModules() as $couponModule) {
$freeShippingForModulesIds[] = $couponModule->getModuleId();
}

View File

@@ -82,13 +82,13 @@ class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface
$freeShippingForCountriesIds = [];
/** @var OrderCouponCountry $couponCountry */
foreach($orderCoupon->getFreeShippingForCountries() as $couponCountry) {
foreach ($orderCoupon->getFreeShippingForCountries() as $couponCountry) {
$freeShippingForCountriesIds[] = $couponCountry->getCountryId();
}
$freeShippingForModulesIds = [];
/** @var OrderCouponModule $couponModule */
foreach($orderCoupon->getFreeShippingForModules() as $couponModule) {
foreach ($orderCoupon->getFreeShippingForModules() as $couponModule) {
$freeShippingForModulesIds[] = $couponModule->getModuleId();
}

View File

@@ -150,7 +150,7 @@ class SmartyAssetsManager
$files = $finder->files()->in($assetSource)->name($file);
if (! empty($files)) {
$url = $this->assetsManager->processAsset(
$assetSource . DS . $file,
$assetSource . DS . self::$assetsDirectory,
@@ -162,8 +162,7 @@ class SmartyAssetsManager
$filters,
$debug
);
}
else {
} else {
Tlog::getInstance()->addError("Asset $assetSource".DS."$file was not found.");
}

View File

@@ -78,8 +78,7 @@ class BaseFacade implements FacadeInterface
{
try {
return AddressQuery::create()->findPk($this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress());
}
catch(\Exception $ex) {
} catch (\Exception $ex) {
throw new \LogicException("Failed to get delivery address (" . $ex->getMessage() . ")");
}
}

View File

@@ -23,8 +23,6 @@ use Thelia\Model\CouponCountry;
use Thelia\Model\CouponCustomerCount;
use Thelia\Model\CouponCustomerCountQuery;
use Thelia\Model\Order;
use Thelia\Model\OrderAddress;
use Thelia\Model\OrderAddressQuery;
/**
* Manage how Coupons could interact with a Checkout
@@ -117,7 +115,7 @@ class CouponManager
$deliveryCountryId = $deliveryAddress->getCountryId();
/** @var CouponCountry $couponCountry */
foreach($couponCountries as $couponCountry) {
foreach ($couponCountries as $couponCountry) {
if ($deliveryCountryId == $couponCountry->getCountryId()) {
$countryValid = true;
break;
@@ -140,7 +138,7 @@ class CouponManager
$shippingModuleId = $order->getDeliveryModuleId();
/** @var CouponModule $couponModule */
foreach($couponModules as $couponModule) {
foreach ($couponModules as $couponModule) {
if ($shippingModuleId == $couponModule->getModuleId()) {
$moduleValid = true;
break;
@@ -273,8 +271,8 @@ class CouponManager
*
* To call when a coupon is consumed
*
* @param \Thelia\Model\Coupon $coupon Coupon consumed
* @param int|null $customerId the ID of the ordering customer
* @param \Thelia\Model\Coupon $coupon Coupon consumed
* @param int|null $customerId the ID of the ordering customer
*
* @return int Usage left after decremental
*/
@@ -318,8 +316,7 @@ class CouponManager
;
$ret = $usageLeft - $newCount;
}
else {
} else {
$usageLeft--;
$coupon->setMaxUsage($usageLeft);

View File

@@ -176,6 +176,7 @@ abstract class CouponAbstract implements CouponInterface
public function setPerCustomerUsageCount($perCustomerUsageCount)
{
$this->perCustomerUsageCount = $perCustomerUsageCount;
return $this;
}
@@ -187,7 +188,6 @@ abstract class CouponAbstract implements CouponInterface
return $this->perCustomerUsageCount;
}
/**
* Return Coupon code (ex: XMAS)
*
@@ -253,14 +253,16 @@ abstract class CouponAbstract implements CouponInterface
/**
* @return array list of country IDs for which shipping is free. All if empty
*/
public function getFreeShippingForCountries() {
public function getFreeShippingForCountries()
{
return $this->freeShippingForCountries;
}
/**
* @return array list of module IDs for which shipping is free. All if empty
*/
public function getFreeShippingForModules() {
public function getFreeShippingForModules()
{
return $this->freeShippingForModules;
}

View File

@@ -15,8 +15,6 @@ namespace Thelia\Coupon\Type;
use Propel\Runtime\Collection\ObjectCollection;
use Thelia\Condition\ConditionCollection;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CouponCountry;
use Thelia\Model\CouponModule;
/**
* Represents a Coupon ready to be processed in a Checkout process
@@ -51,22 +49,22 @@ interface CouponInterface
/**
* Set Coupon
*
* @param FacadeInterface $facade Provides necessary value from Thelia
* @param string $code Coupon code (ex: XMAS)
* @param string $title Coupon title (ex: Coupon for XMAS)
* @param string $shortDescription Coupon short description
* @param string $description Coupon description
* @param array $effects Coupon effects params
* @param bool $isCumulative If Coupon is cumulative
* @param bool $isRemovingPostage If Coupon is removing postage
* @param bool $isAvailableOnSpecialOffers If available on Product already
* on special offer price
* @param bool $isEnabled False if Coupon is disabled by admin
* @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring
* @param FacadeInterface $facade Provides necessary value from Thelia
* @param string $code Coupon code (ex: XMAS)
* @param string $title Coupon title (ex: Coupon for XMAS)
* @param string $shortDescription Coupon short description
* @param string $description Coupon description
* @param array $effects Coupon effects params
* @param bool $isCumulative If Coupon is cumulative
* @param bool $isRemovingPostage If Coupon is removing postage
* @param bool $isAvailableOnSpecialOffers If available on Product already
* on special offer price
* @param bool $isEnabled False if Coupon is disabled by admin
* @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring
* @param ObjectCollection $freeShippingForCountries list of countries which shipping is free. All if empty
* @param ObjectCollection $freeShippingForModules list of modules for which shipping is free. All if empty
* @param bool $perCustomerUsageCount true if usage count is per customer only
* @param bool $perCustomerUsageCount true if usage count is per customer only
*/
public function set(
FacadeInterface $facade,

View File

@@ -18,13 +18,10 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotEqualTo;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Model\Base\CountryI18n;
use Thelia\Model\Base\CountryQuery;
use Thelia\Model\Base\LangQuery;
use Thelia\Model\Base\ModuleQuery;
use Thelia\Model\CountryI18nQuery;
use Thelia\Model\Module;
use Thelia\Model\ModuleI18nQuery;
use Thelia\Module\BaseModule;
/**
@@ -49,7 +46,7 @@ class CouponCreationForm extends BaseForm
$list = CountryQuery::create()->find();
/** @var Country $item */
foreach($list as $item) {
foreach ($list as $item) {
$countries[$item->getId()] = $item->getTitle();
}
@@ -62,7 +59,7 @@ class CouponCreationForm extends BaseForm
$list = ModuleQuery::create()->filterByActivate(BaseModule::IS_ACTIVATED)->filterByType(BaseModule::DELIVERY_MODULE_TYPE)->find();
/** @var Module $item */
foreach($list as $item) {
foreach ($list as $item) {
$modules[$item->getId()] = $item->getTitle();
}

View File

@@ -19,7 +19,6 @@ use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Condition\Operators;
use Thelia\Coupon\Type\RemoveXAmount;
use Thelia\Model\Coupon;
use Thelia\Model\CouponCountry;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Order;