asParagraphs() public method

Each text paragraph is enclosed within a

tag. One or multiple consecutive empty lines divide two paragraphs.

public asParagraphs ( string $value ) : string
$value string the value to be formatted.
return string the formatted result.
コード例 #1
0
ファイル: FormatterTest.php プロジェクト: aivavic/yii2
 public function testAsParagraphs()
 {
     $value = '123';
     $this->assertSame("<p>{$value}</p>", $this->formatter->asParagraphs($value));
     $value = 123;
     $this->assertSame("<p>{$value}</p>", $this->formatter->asParagraphs($value));
     $value = '<>';
     $this->assertSame('<p>&lt;&gt;</p>', $this->formatter->asParagraphs($value));
     $value = "123\n456";
     $this->assertSame("<p>123\n456</p>", $this->formatter->asParagraphs($value));
     $value = "123\n\n456";
     $this->assertSame("<p>123</p>\n<p>456</p>", $this->formatter->asParagraphs($value));
     $value = "123\n\n\n456";
     $this->assertSame("<p>123</p>\n<p>456</p>", $this->formatter->asParagraphs($value));
     $value = "123\r\n456";
     $this->assertSame("<p>123\r\n456</p>", $this->formatter->asParagraphs($value));
     $value = "123\r\n\r\n456";
     $this->assertSame("<p>123</p>\n<p>456</p>", $this->formatter->asParagraphs($value));
     $value = "123\r\n\r\n\r\n456";
     $this->assertSame("<p>123</p>\n<p>456</p>", $this->formatter->asParagraphs($value));
     $value = "123\r456";
     $this->assertSame("<p>123\r456</p>", $this->formatter->asParagraphs($value));
     $value = "123\r\r456";
     $this->assertSame("<p>123</p>\n<p>456</p>", $this->formatter->asParagraphs($value));
     $value = "123\r\r\r456";
     $this->assertSame("<p>123</p>\n<p>456</p>", $this->formatter->asParagraphs($value));
     // null display
     $this->assertSame($this->formatter->nullDisplay, $this->formatter->asParagraphs(null));
 }