Drupal investigation

Groups.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Serializer\Annotation;
  11. use Symfony\Component\Serializer\Exception\InvalidArgumentException;
  12. /**
  13. * Annotation class for @Groups().
  14. *
  15. * @Annotation
  16. * @Target({"PROPERTY", "METHOD"})
  17. *
  18. * @author Kévin Dunglas <dunglas@gmail.com>
  19. */
  20. class Groups
  21. {
  22. /**
  23. * @var array
  24. */
  25. private $groups;
  26. /**
  27. * @param array $data
  28. *
  29. * @throws InvalidArgumentException
  30. */
  31. public function __construct(array $data)
  32. {
  33. if (!isset($data['value']) || !$data['value']) {
  34. throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this)));
  35. }
  36. if (!is_array($data['value'])) {
  37. throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this)));
  38. }
  39. foreach ($data['value'] as $group) {
  40. if (!is_string($group)) {
  41. throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this)));
  42. }
  43. }
  44. $this->groups = $data['value'];
  45. }
  46. /**
  47. * Gets groups.
  48. *
  49. * @return array
  50. */
  51. public function getGroups()
  52. {
  53. return $this->groups;
  54. }
  55. }