. */ /* */ /**********************************************************************************/ namespace Thelia\Coupon; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Thelia\Coupon\Rule\CouponRuleInterface; use Thelia\Exception\InvalidRuleException; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * * Manage a set of v * * @package Coupon * @author Guillaume MOREL * */ class CouponRuleCollection { /** @var array Array of CouponRuleInterface */ protected $rules = array(); /** * Constructor * * @param array $rules Array of CouponRuleInterface * * @throws \Thelia\Exception\InvalidRuleException */ function __construct(array $rules) { foreach ($rules as $rule) { if (!$rule instanceof CouponRuleInterface) { throw new InvalidRuleException(get_class()); } } $this->rules = $rules; } /** * Get Rules * * @return array Array of CouponRuleInterface */ public function getRules() { return $this->rules; } /** * Add a CouponRuleInterface to the Collection * * @param CouponRuleInterface $rule Rule * * @return $this */ public function add(CouponRuleInterface $rule) { $this->rules[] = $rule; return $this; } }