コード例 #1
0
ファイル: Analyser.php プロジェクト: Bluetel-Solutions/Warden
 /**
  * Checks the limits against the actual recorded values and determines whether they have exceeded
  *
  * @return void
  */
 public function checkResults()
 {
     $data = $this->params->all();
     foreach ($data as $key => $value) {
         $failed = $this->expression->evaluate($value['expression'], array('value' => $value['value'], 'limit' => $value['limit']));
         if ($failed) {
             // We throw the exception because the limit has been breached.
             throw new Exceptions\LimitExceededException($value['value'], $value['limit'], $key);
         }
     }
 }
コード例 #2
0
 /**
  * Test that it allows me to add a collector information node
  * And subsequently allows me to set and get
  *
  * @return void
  */
 public function test_can_add_and_get_set()
 {
     $parambag = new CollectorParamBag();
     $parambag->add('request_time', ['type' => 'integer', 'default' => 100, 'limit' => 5, 'value' => '']);
     $this->assertEquals('integer', $parambag->getType('request_time'));
     $this->assertEquals(100, $parambag->getDefault('request_time'));
     $this->assertEquals(5, $parambag->getLimit('request_time'));
     $this->assertEquals('', $parambag->getValue('request_time'));
     $this->assertEquals('value >= limit', $parambag->getExpression('request_time'));
     $parambag->setValue('request_time', 500);
     $parambag->setLimit('request_time', 15);
     $this->assertEquals(500, $parambag->getValue('request_time'));
     $this->assertEquals(15, $parambag->getLimit('request_time'));
     $parambag->setValue('request_time', 10);
     $this->assertEquals(10, $parambag->getValue('request_time'));
     $this->assertEquals(1, count($parambag->all()));
 }