Esempio n. 1
0
 /**
  * Add a new rule to the collection
  * @param Rule $rule
  * @return Rules
  */
 public function add(Rule $rule)
 {
     $userAgent = $this->handleUa($rule->getUserAgent());
     if (isset($this->collection[$userAgent]) && $this->collection[$userAgent] !== $this->defaultRule) {
         throw (new DuplicateRuleException('You can\'t add 2 rules for the same UserAgent'))->setRule($rule);
     }
     $this->collection[$userAgent] = $rule;
     return $this;
 }
Esempio n. 2
0
 public function testUserAgent()
 {
     $this->given($sut = new SUT('UA'))->then->string($sut->getUserAgent())->isEqualTo('UA');
 }