DiDom\Document::format PHP Метод

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

Nicely formats output with indentation and extra space.
public format ( boolean $format = true ) : Document
$format boolean Formats output if true
Результат Document
    public function format($format = true)
    {
        if (!is_bool($format)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be boolean, %s given', __METHOD__, gettype($format)));
        }
        $this->document->formatOutput = $format;
        return $this;
    }

Usage Example

Пример #1
0
 public function testFormat()
 {
     $html = $this->loadFixture('posts.html');
     $document = new Document($html, false);
     $domDocument = $document->getDocument();
     $this->assertFalse($domDocument->formatOutput);
     $document->format();
     $domDocument = $document->getDocument();
     $this->assertTrue($domDocument->formatOutput);
 }