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@0: * @var array Chris@0: */ Chris@0: private $groups; Chris@0: Chris@0: /** Chris@0: * @param array $data 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@0: throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this))); Chris@0: } Chris@0: Chris@0: if (!is_array($data['value'])) { Chris@0: throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this))); Chris@0: } Chris@0: Chris@0: foreach ($data['value'] as $group) { Chris@0: if (!is_string($group)) { Chris@0: throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this))); Chris@0: } Chris@0: } Chris@0: Chris@0: $this->groups = $data['value']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets groups. Chris@0: * Chris@0: * @return array Chris@0: */ Chris@0: public function getGroups() Chris@0: { Chris@0: return $this->groups; Chris@0: } Chris@0: }