asInteger() public method

Formats the value as an integer number by removing any decimal digits without rounding.
public asInteger ( mixed $value, array $options = [], array $textOptions = [] ) : string
$value mixed the value to be formatted.
$options array optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]].
$textOptions array optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
return string the formatted result.
 public function testAsScientific()
 {
     $value = '123';
     $this->assertSame('1.23E+2', $this->formatter->asScientific($value, 2));
     $value = '123456';
     $this->assertSame("1.234560E+5", $this->formatter->asScientific($value));
     $value = '-123456.123';
     $this->assertSame("-1.234561E+5", $this->formatter->asScientific($value));
     // empty input
     $this->assertSame("0", $this->formatter->asInteger(false));
     $this->assertSame("0", $this->formatter->asInteger(""));
     // null display
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asScientific(null));
 }
Exemplo n.º 2
0
 /**
  * @expectedException \yii\base\InvalidParamException
  */
 public function testAsIntegerException2()
 {
     $this->formatter->asInteger('-123abc');
 }
Exemplo n.º 3
0
 /**
  * @expectedException \yii\base\InvalidParamException
  */
 public function testAsIntegerException4()
 {
     $this->formatter->asInteger(false);
 }
Exemplo n.º 4
0
 /**
  * @expectedException \yii\base\InvalidParamException
  */
 public function testAsIntegerException2()
 {
     $this->assertSame("0", $this->formatter->asInteger('-123abc'));
 }