yii\i18n\Formatter::asBoolean PHP Метод

asBoolean() публичный Метод

Formats the value as a boolean.
См. также: booleanFormat
public asBoolean ( mixed $value ) : string
$value mixed the value to be formatted.
Результат string the formatted result.
    public function asBoolean($value)
    {
        if ($value === null) {
            return $this->nullDisplay;
        }
        return $value ? $this->booleanFormat[1] : $this->booleanFormat[0];
    }

Usage Example

Пример #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));
 }
All Usage Examples Of yii\i18n\Formatter::asBoolean