a274c20d85283b2853b2addc784a02a392b20310
[yaffs-website] / vendor / symfony / serializer / Annotation / MaxDepth.php
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 @MaxDepth().
18  *
19  * @Annotation
20  * @Target({"PROPERTY", "METHOD"})
21  *
22  * @author Kévin Dunglas <dunglas@gmail.com>
23  */
24 class MaxDepth
25 {
26     /**
27      * @var int
28      */
29     private $maxDepth;
30
31     public function __construct(array $data)
32     {
33         if (!isset($data['value'])) {
34             throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', \get_class($this)));
35         }
36
37         if (!\is_int($data['value']) || $data['value'] <= 0) {
38             throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a positive integer.', \get_class($this)));
39         }
40
41         $this->maxDepth = $data['value'];
42     }
43
44     public function getMaxDepth()
45     {
46         return $this->maxDepth;
47     }
48 }