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 @MaxDepth(). Chris@0: * Chris@0: * @Annotation Chris@0: * @Target({"PROPERTY", "METHOD"}) Chris@0: * Chris@0: * @author Kévin Dunglas Chris@0: */ Chris@0: class MaxDepth Chris@0: { Chris@0: /** Chris@0: * @var int Chris@0: */ Chris@0: private $maxDepth; Chris@0: Chris@0: public function __construct(array $data) Chris@0: { Chris@0: if (!isset($data['value'])) { Chris@17: throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" should be set.', \get_class($this))); Chris@0: } Chris@0: Chris@17: if (!\is_int($data['value']) || $data['value'] <= 0) { Chris@17: throw new InvalidArgumentException(sprintf('Parameter of annotation "%s" must be a positive integer.', \get_class($this))); Chris@0: } Chris@0: Chris@0: $this->maxDepth = $data['value']; Chris@0: } Chris@0: Chris@0: public function getMaxDepth() Chris@0: { Chris@0: return $this->maxDepth; Chris@0: } Chris@0: }