1<?php
2
3declare(strict_types=1);
4
5namespace JMS\Serializer\Annotation;
6
7use JMS\Serializer\Exception\RuntimeException;
8
9/**
10 * @Annotation
11 * @Target("CLASS")
12 */
13final class ExclusionPolicy
14{
15    public const NONE = 'NONE';
16    public const ALL = 'ALL';
17
18    /**
19     * @var string
20     */
21    public $policy;
22
23    public function __construct(array $values)
24    {
25        if (!\is_string($values['value'])) {
26            throw new RuntimeException('"value" must be a string.');
27        }
28
29        $this->policy = strtoupper($values['value']);
30
31        if (self::NONE !== $this->policy && self::ALL !== $this->policy) {
32            throw new RuntimeException('Exclusion policy must either be "ALL", or "NONE".');
33        }
34    }
35}
36