Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Serializer\Annotation; Chris@0: Chris@0: use Symfony\Component\Serializer\Exception\InvalidArgumentException; Chris@0: Chris@0: /** Chris@0: * Annotation class for @Groups(). Chris@0: * Chris@0: * @Annotation Chris@0: * @Target({"PROPERTY", "METHOD"}) Chris@0: * Chris@0: * @author Kévin Dunglas Chris@0: */ Chris@0: class Groups Chris@0: { Chris@0: /** Chris@14: * @var string[] Chris@0: */ Chris@0: private $groups; Chris@0: Chris@0: /** Chris@0: * @throws InvalidArgumentException Chris@0: */ Chris@0: public function __construct(array $data) Chris@0: { Chris@0: if (!isset($data['value']) || !$data['value']) { Chris@14: throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', \get_class($this))); Chris@0: } Chris@0: Chris@14: $value = (array) $data['value']; Chris@14: foreach ($value as $group) { Chris@14: if (!\is_string($group)) { Chris@14: throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array of strings.', \get_class($this))); Chris@0: } Chris@0: } Chris@0: Chris@14: $this->groups = $value; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets groups. Chris@0: * Chris@14: * @return string[] Chris@0: */ Chris@0: public function getGroups() Chris@0: { Chris@0: return $this->groups; Chris@0: } Chris@0: }