Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/serializer/Annotation/Groups.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\Serializer\Annotation; | |
13 | |
14 use Symfony\Component\Serializer\Exception\InvalidArgumentException; | |
15 | |
16 /** | |
17 * Annotation class for @Groups(). | |
18 * | |
19 * @Annotation | |
20 * @Target({"PROPERTY", "METHOD"}) | |
21 * | |
22 * @author Kévin Dunglas <dunglas@gmail.com> | |
23 */ | |
24 class Groups | |
25 { | |
26 /** | |
27 * @var array | |
28 */ | |
29 private $groups; | |
30 | |
31 /** | |
32 * @param array $data | |
33 * | |
34 * @throws InvalidArgumentException | |
35 */ | |
36 public function __construct(array $data) | |
37 { | |
38 if (!isset($data['value']) || !$data['value']) { | |
39 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" cannot be empty.', get_class($this))); | |
40 } | |
41 | |
42 if (!is_array($data['value'])) { | |
43 throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be an array of strings.', get_class($this))); | |
44 } | |
45 | |
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 } | |
50 } | |
51 | |
52 $this->groups = $data['value']; | |
53 } | |
54 | |
55 /** | |
56 * Gets groups. | |
57 * | |
58 * @return array | |
59 */ | |
60 public function getGroups() | |
61 { | |
62 return $this->groups; | |
63 } | |
64 } |