Attribute.php 746 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * This file is part of the Nette Framework (https://nette.org)
  4. * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
  5. */
  6. declare(strict_types=1);
  7. namespace Nette\PhpGenerator;
  8. use Nette;
  9. /**
  10. * PHP Attribute.
  11. */
  12. final class Attribute
  13. {
  14. use Nette\SmartObject;
  15. /** @var string */
  16. private $name;
  17. /** @var array */
  18. private $args;
  19. public function __construct(string $name, array $args)
  20. {
  21. if (!Helpers::isNamespaceIdentifier($name)) {
  22. throw new Nette\InvalidArgumentException("Value '$name' is not valid attribute name.");
  23. }
  24. $this->name = $name;
  25. $this->args = $args;
  26. }
  27. public function getName(): string
  28. {
  29. return $this->name;
  30. }
  31. public function getArguments(): array
  32. {
  33. return $this->args;
  34. }
  35. }