public function toString() {
        $documentation = preg_replace_callback(
            '@\r?\n@',
            function ($matches) {
                return $matches[0] . ' * ';
            },
            trim($this->getDocumentation())
        );
        if($documentation == '') {
            $documentation = $this->getName();
        }
        $buffer = '<?php
namespace ' . $this->getNamespace() . ';
';
        foreach($this->getUses() as $use) {
            $buffer .= 'use ' . $use . ';' . "\n";
        }
        $buffer .= '/**
 * ' . $documentation . '
 */
' . ($this->isAbstract() ? 'abstract ' : '') . 'class ' . $this->getName() . ' extends ' . $this->getExtends() . (sizeOf($this->getImplements()) > 0 ? ' implements ' . implode(', ', $this->getImplements()) : '') . ' {
';
        foreach($this->getTraits() as $trait) {
            $buffer .= '	use ' . $trait . ';
';
        }
        foreach($this->getConstants() as $name => $value) {
            $buffer .= '	const ' . $name . ' = \'' . str_replace("'", "\\'", $value) . '\';
';
        }
        foreach($this->getVariables() as $variable) {
            $buffer .= $variable->toString();
        }
        foreach($this->getMethods() as $method) {
            $buffer .= $method->toString();
        }
        $buffer .= '}';
        return str_replace("\r\n", "\n", $buffer);
    }