Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/serializer/Annotation/Groups.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
22 * @author Kévin Dunglas <dunglas@gmail.com> | 22 * @author Kévin Dunglas <dunglas@gmail.com> |
23 */ | 23 */ |
24 class Groups | 24 class Groups |
25 { | 25 { |
26 /** | 26 /** |
27 * @var array | 27 * @var string[] |
28 */ | 28 */ |
29 private $groups; | 29 private $groups; |
30 | 30 |
31 /** | 31 /** |
32 * @param array $data | |
33 * | |
34 * @throws InvalidArgumentException | 32 * @throws InvalidArgumentException |
35 */ | 33 */ |
36 public function __construct(array $data) | 34 public function __construct(array $data) |
37 { | 35 { |
38 if (!isset($data['value']) || !$data['value']) { | 36 if (!isset($data['value']) || !$data['value']) { |
39 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this))); | 37 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', \get_class($this))); |
40 } | 38 } |
41 | 39 |
42 if (!is_array($data['value'])) { | 40 $value = (array) $data['value']; |
43 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this))); | 41 foreach ($value as $group) { |
44 } | 42 if (!\is_string($group)) { |
45 | 43 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a string or an array of strings.', \get_class($this))); |
46 foreach ($data['value'] as $group) { | |
47 if (!is_string($group)) { | |
48 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this))); | |
49 } | 44 } |
50 } | 45 } |
51 | 46 |
52 $this->groups = $data['value']; | 47 $this->groups = $value; |
53 } | 48 } |
54 | 49 |
55 /** | 50 /** |
56 * Gets groups. | 51 * Gets groups. |
57 * | 52 * |
58 * @return array | 53 * @return string[] |
59 */ | 54 */ |
60 public function getGroups() | 55 public function getGroups() |
61 { | 56 { |
62 return $this->groups; | 57 return $this->groups; |
63 } | 58 } |