asBoolean() 공개 메소드

Formats the value as a boolean.
또한 보기: booleanFormat
public asBoolean ( mixed $value ) : string
$value mixed the value to be formatted.
리턴 string the formatted result.
예제 #1
0
 public function testAsBoolean()
 {
     $this->assertSame('Yes', $this->formatter->asBoolean(true));
     $this->assertSame('No', $this->formatter->asBoolean(false));
     $this->assertSame('Yes', $this->formatter->asBoolean("111"));
     $this->assertSame('No', $this->formatter->asBoolean(""));
     $this->assertSame('No', $this->formatter->asBoolean(0));
     // null display
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asBoolean(null));
 }
예제 #2
0
 public function testAsBoolean()
 {
     $value = true;
     $this->assertSame('Yes', $this->formatter->asBoolean($value));
     $value = false;
     $this->assertSame('No', $this->formatter->asBoolean($value));
     $value = "111";
     $this->assertSame('Yes', $this->formatter->asBoolean($value));
     $value = "";
     $this->assertSame('No', $this->formatter->asBoolean($value));
     // null display
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asBoolean(null));
 }