ItemSerializedName.php 487 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\Serializer;
  3. use Doctrine\Common\Annotations\Annotation;
  4. /**
  5. * @Annotation
  6. */
  7. class ItemSerializedName {
  8. private $origName;
  9. public function __construct(array $data) {
  10. $this->origName = $data['value'] ?? null;
  11. if (empty($this->origName))
  12. throw new \InvalidArgumentException(sprintf("Value must me non-empty for %s", static::class));
  13. }
  14. public function getFieldName(): string {
  15. return $this->origName;
  16. }
  17. }