php-cs fixer passed.

This commit is contained in:
Franck Allimant
2014-06-12 17:10:38 +02:00
parent e9a0661938
commit ec26ebac32
20 changed files with 60 additions and 81 deletions

View File

@@ -112,8 +112,8 @@ class Coupon extends BaseAction implements EventSubscriberInterface
/**
* Clear all coupons in session.
*/
public function clearAllCoupons() {
public function clearAllCoupons()
{
$this->request->getSession()->setConsumedCoupons(array());
}

View File

@@ -469,7 +469,6 @@ final class TheliaEvents
*/
const COUPON_CLEAR_ALL = "action.clear_all_coupon";
/**
* Sent just before an attempt to use a Coupon
*/

View File

@@ -280,8 +280,7 @@ class CouponManager
{
if ($coupon->isUsageUnlimited()) {
$ret = true;
}
else {
} else {
$ret = false;
try {

View File

@@ -12,7 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CartItem;
@@ -29,15 +28,15 @@ abstract class AbstractRemove extends CouponAbstract implements AmountAndPercent
*
* @param Array $effects the Coupon effects params
*/
public abstract function setFieldsValue($effects);
abstract public function setFieldsValue($effects);
/**
* Get the discount for a specific cart item.
*
* @param CartItem $cartItem the cart item
* @return float the discount value
* @param CartItem $cartItem the cart item
* @return float the discount value
*/
public abstract function getCartItemDiscount($cartItem);
abstract public function getCartItemDiscount($cartItem);
/**
* @inheritdoc
@@ -126,4 +125,4 @@ abstract class AbstractRemove extends CouponAbstract implements AmountAndPercent
{
return $fieldValue;
}
}
}

View File

@@ -35,15 +35,15 @@ abstract class AbstractRemoveOnAttributeValues extends CouponAbstract implements
* Set the value of specific coupon fields.
* @param Array $effects the Coupon effects params
*/
public abstract function setFieldsValue($effects);
abstract public function setFieldsValue($effects);
/**
* Get the discount for a specific cart item.
*
* @param CartItem $cartItem the cart item
* @return float the discount value
* @param CartItem $cartItem the cart item
* @return float the discount value
*/
public abstract function getCartItemDiscount($cartItem);
abstract public function getCartItemDiscount($cartItem);
/**
* @inheritdoc
@@ -126,7 +126,7 @@ abstract class AbstractRemoveOnAttributeValues extends CouponAbstract implements
* using the provided template file, and a list of specific input fields.
*
* @param string $templateName the path to the template
* @param array $otherFields the list of additional fields fields
* @param array $otherFields the list of additional fields fields
*
* @return string the rendered template.
*/

View File

@@ -33,15 +33,15 @@ abstract class AbstractRemoveOnCategories extends CouponAbstract implements Amou
*
* @param Array $effects the Coupon effects params
*/
public abstract function setFieldsValue($effects);
abstract public function setFieldsValue($effects);
/**
* Get the discount for a specific cart item.
*
* @param CartItem $cartItem the cart item
* @return float the discount value
* @param CartItem $cartItem the cart item
* @return float the discount value
*/
public abstract function getCartItemDiscount($cartItem);
abstract public function getCartItemDiscount($cartItem);
/**
* @inheritdoc
@@ -75,7 +75,6 @@ abstract class AbstractRemoveOnCategories extends CouponAbstract implements Amou
$this->category_list = isset($effects[self::CATEGORIES_LIST]) ? $effects[self::CATEGORIES_LIST] : array();
if (! is_array($this->category_list)) $this->category_list = array($this->category_list);
return $this;
}
/**
@@ -147,4 +146,4 @@ abstract class AbstractRemoveOnCategories extends CouponAbstract implements Amou
return $fieldValue;
}
}
}

View File

@@ -35,15 +35,15 @@ abstract class AbstractRemoveOnProducts extends CouponAbstract implements Amount
*
* @param Array $effects the Coupon effects params
*/
public abstract function setFieldsValue($effects);
abstract public function setFieldsValue($effects);
/**
* Get the discount for a specific cart item.
*
* @param CartItem $cartItem the cart item
* @return float the discount value
* @param CartItem $cartItem the cart item
* @return float the discount value
*/
public abstract function getCartItemDiscount($cartItem);
abstract public function getCartItemDiscount($cartItem);
/**
* @inheritdoc

View File

@@ -12,10 +12,6 @@
namespace Thelia\Coupon\Type;
use Propel\Runtime\Collection\ObjectCollection;
use Thelia\Condition\ConditionCollection;
use Thelia\Coupon\FacadeInterface;
/**
* Represents a Coupon ready to be processed in a Checkout process
*
@@ -35,18 +31,17 @@ interface AmountAndPercentageCouponInterface
/**
* Get the discount for a specific cart item.
*
* @param CartItem $cartItem the cart item
* @return float the discount value
* @param CartItem $cartItem the cart item
* @return float the discount value
*/
public function getCartItemDiscount($cartItem);
/**
* Renders the template which implements coupon specific user-input,
* using the provided template file, and a list of specific input fields.
*
* @param string $templateName the path to the template
* @param array $otherFields the list of additional fields fields
* @param array $otherFields the list of additional fields fields
*
* @return string the rendered template.
*/
@@ -61,4 +56,4 @@ interface AmountAndPercentageCouponInterface
*
*/
public function checkBaseCouponFieldValue($fieldName, $fieldValue);
}
}

View File

@@ -32,19 +32,21 @@ Trait AmountCouponTrait {
*
* @return string the percentage field name
*/
protected abstract function getAmountFieldName();
abstract protected function getAmountFieldName();
/**
* @inheritdoc
*/
protected function setFieldsValue($effects) {
protected function setFieldsValue($effects)
{
$this->amount = $effects[$this->getAmountFieldName()];
}
/**
* @inheritdoc
*/
public function getCartItemDiscount($cartItem) {
public function getCartItemDiscount($cartItem)
{
return $cartItem->getQuantity() * $this->amount;
}
@@ -88,4 +90,4 @@ Trait AmountCouponTrait {
return $fieldValue;
}
}
}

View File

@@ -499,4 +499,4 @@ abstract class CouponAbstract implements CouponInterface
return $effects;
}
}
}

View File

@@ -29,19 +29,21 @@ Trait PercentageCouponTrait {
*
* @return string the percentage field name
*/
protected abstract function getPercentageFieldName();
abstract protected function getPercentageFieldName();
/**
* @inheritdoc
*/
protected function setFieldsValue($effects) {
protected function setFieldsValue($effects)
{
$this->percentage = $effects[$this->getPercentageFieldName()];
}
/**
* @inheritdoc
*/
public function getCartItemDiscount($cartItem) {
public function getCartItemDiscount($cartItem)
{
return $cartItem->getQuantity() * $cartItem->getPrice() * ($this->percentage / 100);
}
@@ -87,4 +89,4 @@ Trait PercentageCouponTrait {
return $fieldValue;
}
}
}

View File

@@ -12,8 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
/**
* Allow to remove an amount from the checkout total
*
@@ -27,7 +25,8 @@ class RemoveAmountOnAttributeValues extends AbstractRemoveOnAttributeValues
/** @var string Service Id */
protected $serviceId = 'thelia.coupon.type.remove_amount_on_attribute_av';
protected function getAmountFieldName() {
protected function getAmountFieldName()
{
return self::AMOUNT_FIELD_NAME;
}
/**

View File

@@ -12,11 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CartItem;
use Thelia\Model\Category;
/**
* Allow to remove an amount from the checkout total
*
@@ -30,7 +25,8 @@ class RemoveAmountOnCategories extends AbstractRemoveOnCategories
/** @var string Service Id */
protected $serviceId = 'thelia.coupon.type.remove_amount_on_categories';
protected function getAmountFieldName() {
protected function getAmountFieldName()
{
return self::AMOUNT_FIELD_NAME;
}

View File

@@ -12,9 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CartItem;
use Thelia\Model\Product;
/**
@@ -30,7 +27,8 @@ class RemoveAmountOnProducts extends AbstractRemoveOnProducts
/** @var string Service Id */
protected $serviceId = 'thelia.coupon.type.remove_amount_on_products';
protected function getAmountFieldName() {
protected function getAmountFieldName()
{
return self::AMOUNT_FIELD_NAME;
}
@@ -69,4 +67,4 @@ class RemoveAmountOnProducts extends AbstractRemoveOnProducts
{
return $this->callDrawBackOfficeInputs('coupon/type-fragments/remove-amount-on-products.html');
}
}
}

View File

@@ -12,8 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
/**
* Allow to remove an amount from the checkout total
*
@@ -32,7 +30,8 @@ class RemovePercentageOnAttributeValues extends AbstractRemoveOnAttributeValues
/**
* @inheritdoc
*/
protected function getPercentageFieldName() {
protected function getPercentageFieldName()
{
return self::PERCENTAGE;
}

View File

@@ -12,11 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CartItem;
use Thelia\Model\Category;
/**
* @author Franck Allimant <franck@cqfdev.fr>
*/
@@ -32,7 +27,8 @@ class RemovePercentageOnCategories extends AbstractRemoveOnCategories
/**
* @inheritdoc
*/
protected function getPercentageFieldName() {
protected function getPercentageFieldName()
{
return self::PERCENTAGE;
}

View File

@@ -12,9 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\FacadeInterface;
use Thelia\Model\CartItem;
use Thelia\Model\Product;
/**
@@ -35,7 +32,8 @@ class RemovePercentageOnProducts extends AbstractRemoveOnProducts
/**
* @inheritdoc
*/
protected function getPercentageFieldName() {
protected function getPercentageFieldName()
{
return self::PERCENTAGE;
}
@@ -74,4 +72,4 @@ class RemovePercentageOnProducts extends AbstractRemoveOnProducts
{
return $this->callDrawBackOfficeInputs('coupon/type-fragments/remove-percentage-on-products.html');
}
}
}

View File

@@ -12,8 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
/**
* Allow to remove an amount from the checkout total
*
@@ -28,7 +26,8 @@ class RemoveXAmount extends AbstractRemove
/** @var string Service Id */
protected $serviceId = 'thelia.coupon.type.remove_x_amount';
protected function getAmountFieldName() {
protected function getAmountFieldName()
{
return self::AMOUNT_FIELD_NAME;
}
@@ -73,4 +72,4 @@ class RemoveXAmount extends AbstractRemove
{
return $this->callDrawBackOfficeInputs('coupon/type-fragments/remove-x-amount.html');
}
}
}

View File

@@ -12,9 +12,6 @@
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\FacadeInterface;
/**
* @package Coupon
* @author Guillaume MOREL <gmorel@openstudio.fr>, Franck Allimant <franck@cqfdev.fr>
@@ -32,7 +29,8 @@ class RemoveXPercent extends AbstractRemove
/**
* @inheritdoc
*/
protected function getPercentageFieldName() {
protected function getPercentageFieldName()
{
return self::INPUT_PERCENTAGE_NAME;
}

View File

@@ -268,7 +268,8 @@ class Coupon extends BaseCoupon
return CouponModuleQuery::create()->filterByCouponId($this->getId())->find();
}
public function isUsageUnlimited() {
public function isUsageUnlimited()
{
return $this->getMaxUsage() == self::UNLIMITED_COUPON_USE;
}
/**