예제 #1
0
 /**
  * 
  * @param string $text
  * @param int $type
  * 
  * @throws \Exception if maximum number of items reached
  * 
  * @return \sfAltumoPlugin\Geckoboard\Widget\TextWidget
  */
 public function addItem($text, $type = self::TYPE_NONE)
 {
     $item = new \stdClass();
     // pre-validate and set text
     $item->text = \Altumo\Validation\Strings::assertString($text);
     // pre-validate and set type
     $item->type = \Altumo\Validation\Numerics::assertInteger($type);
     if (count($this->getItems()) > self::MAXIMUM_ITEM_COUNT - 1) {
         throw new \Exception("Cannot add new item, maximum count reached");
     }
     // add to items
     $this->items[] = $item;
     return $this;
 }
예제 #2
0
 /**
  * Tests Numerics::assertInteger()
  * 
  */
 public function testAssertInteger()
 {
     $input = '7215';
     $output = \Altumo\Validation\Numerics::assertInteger($input);
     $this->assertTrue(is_integer($output));
     $input = 7215.0;
     $output = \Altumo\Validation\Numerics::assertInteger($input);
     $this->assertTrue(is_integer($output));
     $input = 7215;
     $output = \Altumo\Validation\Numerics::assertInteger($input);
     $this->assertTrue(is_integer($output));
     try {
         $input = 72.56;
         $output = \Altumo\Validation\Numerics::assertInteger($input);
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $this->assertTrue(true);
     }
     $input = 0;
     $output = \Altumo\Validation\Numerics::assertInteger($input);
     $this->assertTrue(is_integer($output));
 }
예제 #3
0
파일: Currency.php 프로젝트: homer6/altumo
 /**
  * Converts cents to dollars.
  * 
  * 
  * @param int $amount
  * 
  * @return float
  */
 static function getCentsAsDollars($amount)
 {
     $amount = \Altumo\Validation\Numerics::assertInteger($amount);
     return $amount / 100;
 }
예제 #4
0
 /**
  * Sets the offset for retrieved data
  * 
  * @param integer $offset
  * 
  * @return RawQuery Returns itself
  */
 public function setOffset($offset)
 {
     $this->offset = \Altumo\Validation\Numerics::assertInteger($offset);
     return $this;
 }