public function writePopulate(WriterInterface $writer)
    {
        $writer
            ->write('/**')
            ->write(' * Populate entity with the given data.')
            ->write(' * The set* method will be used to set the data.')
            ->write(' *')
            ->write(' * @param array $data')
            ->write(' * @return boolean')
            ->write(' */')
            ->write('public function populate(array $data = array())')
            ->write('{')
            ->indent()
                ->write('foreach ($data as $field => $value) {')
                ->indent()
                    ->write('$setter = sprintf(\'set%s\', ucfirst(')
                    ->indent()
                        ->write('str_replace(\' \', \'\', ucwords(str_replace(\'_\', \' \', $field)))')
                    ->outdent()
                    ->write('));')
                    ->write('if (method_exists($this, $setter)) {')
                    ->indent()
                        ->write('$this->{$setter}($value);')
                    ->outdent()
                    ->write('}')
                ->outdent()
                ->write('}')
                ->write('')
                ->write('return true;')
            ->outdent()
            ->write('}')
            ->write('')
        ;

        return $this;
    }