| @@ 183-190 (lines=8) @@ | ||
| 180 | * |
|
| 181 | * @return static The enum instance for computed value |
|
| 182 | */ |
|
| 183 | public function withFlags(int $flags): self |
|
| 184 | { |
|
| 185 | if (!static::accepts($flags)) { |
|
| 186 | throw new InvalidValueException($flags, static::class); |
|
| 187 | } |
|
| 188 | ||
| 189 | return static::get($this->value | $flags); |
|
| 190 | } |
|
| 191 | ||
| 192 | /** |
|
| 193 | * Computes a new value without given flags, and returns the corresponding instance. |
|
| @@ 201-208 (lines=8) @@ | ||
| 198 | * |
|
| 199 | * @return static The enum instance for computed value |
|
| 200 | */ |
|
| 201 | public function withoutFlags(int $flags): self |
|
| 202 | { |
|
| 203 | if (!static::accepts($flags)) { |
|
| 204 | throw new InvalidValueException($flags, static::class); |
|
| 205 | } |
|
| 206 | ||
| 207 | return static::get($this->value & ~$flags); |
|
| 208 | } |
|
| 209 | } |
|
| 210 | ||
| @@ 25-32 (lines=8) @@ | ||
| 22 | /** |
|
| 23 | * {@inheritdoc} |
|
| 24 | */ |
|
| 25 | public static function readableFor($value): string |
|
| 26 | { |
|
| 27 | if (!static::accepts($value)) { |
|
| 28 | throw new InvalidValueException($value, static::class); |
|
| 29 | } |
|
| 30 | ||
| 31 | return static::readables()[$value]; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * {@inheritdoc} |
|