Generates entity methods

@return EntityGenerator
179571
private function generateMethods(): EntityGenerator
    {
        $this->entityClass
            ->addMethod('getId')
            ->setVisibility('public')
            ->addComment('Returns ' . strtolower($this->entityData['class']) . ' ID' . PHP_EOL)
            ->addComment('@return int')
            ->addBody('return $this->id;')
            ->setReturnType('int');

        foreach ($this->entityData['properties'] as $name => $type) {
            $this
                ->generateGetter($name, $type)
                ->generateSetter($name, $type);
        }

        return $this;
    }
337288
private function generateClasses()
    {
        foreach($this->ref->getClasses() as $class)
        {
            if($class->isInterface())
            {
                $this->generateInterface($class);
            }
            else if($class->isTrait())
            {
                $this->generateTrait($class);
            }
            else
            {
                $this->generateClass($class);
            }
        }
    }
954737
protected function generateFields(Entity $entity)
    {
        $properties = [];
        $descriptor = $entity->getDescriptor();
        $fields     = $descriptor->getFieldList() ?: [];
        $extensions = $descriptor->getExtensionList() ?: [];

        $properties[] = PropertyGenerator::fromArray([
            'name'       => $this->getUniqueFieldName($descriptor, 'unknownFieldSet'),
            'visibility' => PropertyGenerator::VISIBILITY_PROTECTED,
            'docblock'   => [
                'tags'   => [
                    [
                        'name'        => 'var',
                        'description' => '\Protobuf\UnknownFieldSet',
                    ]
                ]
            ]
        ]);

        $properties[] = PropertyGenerator::fromArray([
            'name'       => $this->getUniqueFieldName($descriptor, 'extensions'),
            'visibility' => PropertyGenerator::VISIBILITY_PROTECTED,
            'docblock'   => [
                'tags'   => [
                    [
                        'name'        => 'var',
                        'description' => '\Protobuf\Extension\ExtensionFieldMap',
                    ]
                ]
            ]
        ]);

        foreach ($fields as $field) {
            $properties[] = $this->generateField($entity, $field);
        }

        return $properties;
    }
983911
public function build()
    {
        $cm = $this->builder->getClassMetadata();
        if ($this->generatedValue) {
            $cm->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $this->generatedValue));
        }
        if ($this->version) {
            $cm->setVersionMapping($this->mapping);
        }
        $cm->mapField($this->mapping);
        if ($this->sequenceDef) {
            $cm->setSequenceGeneratorDefinition($this->sequenceDef);
        }
        return $this->builder;
    }
1086143
protected function getEntities() {
        if (!$this->_entities) {
            $this->_entities = new EntityList($this->version, $this->solution['sid']);
        }

        return $this->_entities;
    }
934243
public function getGeneratorStrategy()
    {
        if (!isset($this->generatorStrategy)) {
            $this->generatorStrategy = new FileWriterGeneratorStrategy(new FileLocator($this->getPath()));
        }

        return $this->generatorStrategy;
    }
149787
public function toEntity(): EntityInterface
    {
        $data = [];

        $entityProvider = $this->getEntityProvider();
        foreach (get_object_vars($this) as $property => $value) {
            $method = Inflector::variable('get ' . $property);

            if (method_exists($this, $method) && is_callable([$this, $method])) {
                $field = Inflector::underscore($property);
                $data[$field] = $this->$method();
            }
        }

        $entity = new $entityProvider($data);

        return $entity;
    }
443444
protected function generateProperties(Entity $entity)
    {
        $descriptor = $entity->getDescriptor();
        $class      = $entity->getNamespacedName();
        $properties = $this->generateConstants($entity);
        $values     = $descriptor->getValueList() ?: [];

        foreach ($values as $value) {
            $properties[] = PropertyGenerator::fromArray([
                'static'       => true,
                'name'         => $value->getName(),
                'visibility'   => PropertyGenerator::VISIBILITY_PROTECTED,
                'docblock'     => [
                    'tags'     => [
                        [
                            'name'        => 'var',
                            'description' => $class,
                        ]
                    ]
                ]
            ]);
        }

        foreach ($properties as $value) {
            $value->getDocblock()->setWordWrap(false);
        }

        return $properties;
    }
93925
protected function createGenerator()
    {
        $filesystem = $this->getContainer()->get('filesystem');
        $registry = $this->getContainer()->get('doctrine');

        return new DefaultPagePartGenerator($filesystem, $registry, '/pagepart', $this->assistant, $this->getContainer());
    }
143868
protected function generateServicesClasses()
    {
        foreach ($this->getGenerator()->getServices(true) as $service) {
            $file = new ServiceFile($this->generator, $service->getPackagedName());
            $file->setModel($service)->write();
        }
        return $this;
    }
748825
public function create()
    {
        $entityClass = $this->getEntityName();

        $reflection = new \ReflectionClass($entityClass);

        if ($reflection->isAbstract()) {
            throw RuntimeException::createAbstract($entityClass);
        }

        return new $entityClass();
    }
948452
public function generate(EntityPackage $entity_package)
    {
        $classes = $this->content_provider->getPackageContent($entity_package)->getClasses();
        foreach ($classes as $package_class) {
            /* @var $package_class PackageClass */
            $this->writeIfDebug(
                '        - Finding traits for <info>' . $package_class->getName() . '</info>.'
            );
            $traits = $this->recursivelyFindUseStatementsFor($entity_package, $package_class);
            $this->generateTrait($package_class, array_unique($traits, SORT_REGULAR));
        }
    }
481586
protected function getEntityGenerator()
    {
        $entityGenerator = new EntityGenerator();
        $entityGenerator->setFieldVisibility(EntityGenerator::FIELD_VISIBLE_PROTECTED);
        $entityGenerator->setGenerateAnnotations(false);
        $entityGenerator->setGenerateStubMethods(true);
        $entityGenerator->setRegenerateEntityIfExists(false);
        $entityGenerator->setUpdateEntityIfExists(true);
        $entityGenerator->setNumSpaces(4);
        $entityGenerator->setAnnotationPrefix('ORM\\');

        if ($this->configuration['with_interface']) {
            $entityGenerator->setClassToInterface($this->configuration['namespace'] . '\\' . $this->model.'Interface');
        }

        return $entityGenerator;
    }
937707
public function generate()
    {
        $saved = $this->factoryMuffin->isPendingOrSaved($this->model);

        return call_user_func($this->kind, $this->model, $saved);
    }
597186
private function generateGetter(string $name, string $type): EntityGenerator
    {
        if ('datetime' === $type) {
            $type = '\DateTime';
        }

        $this->entityClass
            ->addMethod('get' . ucfirst($name))
            ->setVisibility('public')
            ->addComment('Returns ' . strtolower($this->entityData['class']) . ' ' . $name . PHP_EOL)
            ->addComment('@return ' . $type)
            ->setReturnType($type)
            ->addBody('return $this->' . $name . ';');

        return $this;
    }
58414
protected function generateToStreamMethod(Entity $entity)
    {
        $lines   = $this->generateBody($entity);
        $body    = implode(PHP_EOL, $lines);
        $method  = MethodGenerator::fromArray([
            'name'       => 'toStream',
            'body'       => $body,
            'parameters' => [
                [
                    'name'          => 'configuration',
                    'type'          => '\Protobuf\Configuration',
                    'defaultValue'  => null
                ]
            ],
            'docblock'   => [
                'shortDescription' => "{@inheritdoc}"
            ]
        ]);

        return $method;
    }
1372019
public function getEntityGenerator( PgClass $pgclass, array $options, $entityFileStore )
    {

        // build entity
        $tags = $this->getNormalityTags();

        $generators = array(
            'Entity' => '\Bond\Normality\Generate\Entity',
            'Link' => '\Bond\Normality\Generate\Entity\Link',
            'Child' => '\Bond\Normality\Generate\Entity\Child',
        );

        if( isset( $tags['entity'] ) ) {
            $entity = $tags['entity'];
        } elseif ( $parent = $this->get('parent') ) {
            $entity = 'Child';
        } else {
            $entity = 'Entity';
        }

        foreach( $generators as $key => $generator ) {

            if( in_array( strtolower( $entity ), array( strtolower( $key ), strtolower( $generator ) ) ) ) {

                $ref = new \ReflectionClass( $generator );
                return $ref->newInstance( $this, $db, $options, $entityFileStore );

            }

        }

        throw new \RuntimeException( "No generator found for `{entity}` and relation `{$this->get('name')}`" );

    }