/** * Pretty print with indentation. * * @param $indentLevel * @param int $spacesPerIndent * @return string */ public function prettyPrint($indentLevel, $spacesPerIndent = 4) { $indent = str_repeat(str_repeat(' ', $spacesPerIndent), $indentLevel); $resultString = $indent . $this->name; if (!is_null($this->value)) { $resultString .= " " . $this->value; } if (is_null($this->getChildScope())) { $resultString .= ";"; } else { $resultString .= " {"; } if (false === $this->hasComment()) { $resultString .= "\n"; } else { if (false === $this->getComment()->isMultiline()) { $resultString .= " " . $this->comment->prettyPrint(0, 0); } else { $comment = $this->getComment()->prettyPrint($indentLevel, $spacesPerIndent); $resultString = $comment . $resultString; } } if (!is_null($this->getChildScope())) { $resultString .= "" . $this->childScope->prettyPrint($indentLevel, $spacesPerIndent) . $indent . "}\n"; } return $resultString; }