Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function isApplicableTo(Rule $rule)
 {
     return null !== $rule->getResult();
 }
Ejemplo n.º 2
0
 /**
  * @param Rule $rule
  *
  * @return bool
  */
 public function isApplicableTo(Rule $rule)
 {
     $userTypes = Rule::getUserTypes();
     return null !== $rule->getUser() && Rule::RECEIVER_USER === $userTypes[$rule->getUserType()];
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function isApplicableTo(Rule $rule)
 {
     return null !== $rule->getOccurrence();
 }
Ejemplo n.º 4
0
 public function doerProvider()
 {
     $log = new Log();
     $action = uniqid();
     $user = new User();
     $rule = new BadgeRule();
     $rule->setAction($action)->setUser($user)->setUserType(0);
     $badge = new Badge();
     $rule2 = new BadgeRule();
     $rule2->setAction($action)->setUser($user)->setUserType(0)->setBadge($badge);
     $log2 = new Log();
     $log2->setDetails(array('badge' => array('id' => $badge->getId())));
     $badge2 = new Badge();
     $badge2->setId(rand(PHP_INT_MAX / 2 + 1, PHP_INT_MAX));
     $rule3 = new BadgeRule();
     $rule3->setAction($action)->setUser($user)->setUserType(0)->setBadge($badge2);
     $log3 = new Log();
     $log3->setDetails(array('badge' => array('id' => rand(0, PHP_INT_MAX / 2))));
     $rule4 = new BadgeRule();
     $rule4->setAction($action)->setUser($user)->setUserType(0)->setResult(rand(0, PHP_INT_MAX))->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_EQUAL));
     $result = rand(0, PHP_INT_MAX);
     $log4 = new Log();
     $log4->setDetails(array('result' => $result));
     $rule5 = new BadgeRule();
     $rule5->setAction($action)->setUser($user)->setUserType(0)->setResult($result - 1)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_EQUAL));
     $rule6 = new BadgeRule();
     $rule6->setAction($action)->setUser($user)->setUserType(0)->setResult($result)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_EQUAL));
     $log5 = new Log();
     $log5->setDetails(array('result' => 12));
     $rule7 = new BadgeRule();
     $rule7->setAction($action)->setUser($user)->setUserType(0)->setResult(9)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_SUPERIOR));
     $rule8 = new BadgeRule();
     $rule8->setAction($action)->setUser($user)->setUserType(0)->setResult(42)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_SUPERIOR));
     $rule9 = new BadgeRule();
     $rule9->setAction($action)->setUser($user)->setUserType(0)->setResult(12)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_SUPERIOR));
     $rule10 = new BadgeRule();
     $rule10->setAction($action)->setUser($user)->setUserType(0)->setResult(9)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_SUPERIOR_EQUAL));
     $rule11 = new BadgeRule();
     $rule11->setAction($action)->setUser($user)->setUserType(0)->setResult(12)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_SUPERIOR_EQUAL));
     $log6 = new Log();
     $log6->setDetails(array('result' => 9));
     $rule12 = new BadgeRule();
     $rule12->setAction($action)->setUser($user)->setUserType(0)->setResult(12)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_SUPERIOR_EQUAL));
     $rule13 = new BadgeRule();
     $rule13->setAction($action)->setUser($user)->setUserType(0)->setResult(12)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_INFERIOR));
     $log7 = new Log();
     $log7->setDetails(array('result' => 42));
     $rule14 = new BadgeRule();
     $rule14->setAction($action)->setUser($user)->setUserType(0)->setResult(12)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_INFERIOR_EQUAL));
     $rule15 = new BadgeRule();
     $rule15->setAction($action)->setUser($user)->setUserType(0)->setResult(12)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_SUPERIOR_EQUAL));
     $rule16 = new BadgeRule();
     $rule16->setAction($action)->setUser($user)->setUserType(0)->setResult(9)->setResultComparison(Rule::getResultComparisonTypeValue(Rule::RESULT_INFERIOR_EQUAL));
     return array(array($user, $action, $rule, array(), false), array($user, $action, $rule, array($log), array($log)), array($user, $action, $rule2, array($log2), array($log2)), array($user, $action, $rule2, array(), false), array($user, $action, $rule3, array($log3), false), array($user, $action, $rule4, array(), false), array($user, $action, $rule5, array($log4), false), array($user, $action, $rule6, array($log4), array($log4)), array($user, $action, $rule7, array($log5), array($log5)), array($user, $action, $rule8, array($log5), false), array($user, $action, $rule9, array($log5), false), array($user, $action, $rule10, array($log5), array($log5)), array($user, $action, $rule11, array($log5), array($log5)), array($user, $action, $rule12, array($log6), false), array($user, $action, $rule13, array($log6), array($log6)), array($user, $action, $rule13, array($log7), false), array($user, $action, $rule13, array($log5), false), array($user, $action, $rule14, array($log6), array($log6)), array($user, $action, $rule15, array($log5), array($log5)), array($user, $action, $rule16, array($log5), false));
 }
Ejemplo n.º 5
0
 /**
  * @param Rule $rule
  *
  * @return bool
  */
 public function isApplicableTo(Rule $rule)
 {
     return !is_null($rule->getActiveFrom()) || !is_null($rule->getActiveUntil());
 }
Ejemplo n.º 6
0
 /**
  * @param Rule $rule
  *
  * @return bool
  */
 public function isApplicableTo(Rule $rule)
 {
     return $rule instanceof BadgeRule && null !== $rule->getBadge();
 }