You are here

public function Groups::__construct in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Annotation/Groups.php \Symfony\Component\Serializer\Annotation\Groups::__construct()

Parameters

array $data:

Throws

InvalidArgumentException

File

vendor/symfony/serializer/Annotation/Groups.php, line 36

Class

Groups
Annotation class for @Groups().

Namespace

Symfony\Component\Serializer\Annotation

Code

public function __construct(array $data) {
  if (!isset($data['value']) || !$data['value']) {
    throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this)));
  }
  if (!is_array($data['value'])) {
    throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this)));
  }
  foreach ($data['value'] as $group) {
    if (!is_string($group)) {
      throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this)));
    }
  }
  $this->groups = $data['value'];
}