4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Serializer\Annotation;
14 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
17 * Annotation class for @Groups().
20 * @Target({"PROPERTY", "METHOD"})
22 * @author Kévin Dunglas <dunglas@gmail.com>
32 * @throws InvalidArgumentException
34 public function __construct(array $data)
36 if (!isset($data['value']) || !$data['value']) {
37 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', \get_class($this)));
40 $value = (array) $data['value'];
41 foreach ($value as $group) {
42 if (!\is_string($group)) {
43 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array of strings.', \get_class($this)));
47 $this->groups = $value;
55 public function getGroups()