/** * Manipulate document. * * @throws \Exception If a broken rule is executed and silent mode is not enabled. * * @return string */ public function manipulate() { foreach ($this->rules as $rule) { try { $nodeList = $rule->query($this->document); foreach ($nodeList as $node) { $rule->apply($node); } } catch (\Exception $e) { if (!$this->isSilentMode()) { throw $e; } } } return $this->converter->toHtml($this->document); }