Example #1
0
 public function testAdd()
 {
     $comment = new Comment('');
     $this->assertFalse($comment->has('tag'));
     $comment->add('tag', 'value');
     $this->assertTrue($comment->has('tag'));
     $this->assertEquals('value', $comment->get('tag'));
 }
 /**
  * @param Comment $comment
  * @param AnnotationMetadata $metadata
  */
 private function collectDefaultAttributeMetadata(Comment $comment, AnnotationMetadata $metadata)
 {
     //@DefaultAttribute
     if ($comment->has('DefaultAttribute')) {
         $metadata->defaultAttribute = $comment->get('DefaultAttribute');
     }
 }
 /**
  * @param Comment $comment
  * @param         $property
  * @param Entity  $entity
  *
  * @return string The field name.
  */
 private function processField(Comment $comment, $property, Entity $entity)
 {
     /** @var \ORMiny\Annotations\Field $fieldAnnotation */
     $fieldAnnotation = current($comment->getAnnotationType(FieldAnnotation::class));
     if ($fieldAnnotation->name === null) {
         $fieldAnnotation->name = $property;
     }
     $field = new Field($this->createSetter($entity, $property, $fieldAnnotation), $this->createGetter($entity, $property, $fieldAnnotation));
     $fieldName = $entity->addField($fieldAnnotation->name, $field);
     if ($comment->has('Id')) {
         if ($entity->getPrimaryKey() !== null) {
             throw new EntityDefinitionException("Compound primary key is not supported.");
         }
         $entity->setPrimaryKey($fieldName);
     }
 }