Skip to content

Commit 3234db4

Browse files
committed
Adding package specific ForbiddenOperation exception
1 parent ce80d08 commit 3234db4

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
99
- Support for `Stringable` instances added to `Item::from`, the instances will be converted to the string data type.
1010
- Support for the upcoming `Date` data type in `Item`. (see https://httpwg.org/http-extensions/draft-ietf-httpbis-sfbis.html)
1111
- date type is represented as a `DateTimeImmutable` object.
12-
- `Item::isDate` tells whether the instance represents a `Date` DataType.
13-
- `ParameterAccess` interface updated with 4 new methods to ease parameter members modification.
12+
- `ParameterAccess` interface updated with new methods to ease parameter members modification.
1413
- `Parameter::create` named constructor to create a new instance without any parameter.
1514
- `Dictionnary::create` named constructor to create a new instance without any parameter.
1615
- `Type` Enum to list all possible Item Type supported.
1716
- `Value` Interface is introduced with `Item` being the only available implementation.
1817
- `MemberOrderedMap::add` and `MemberOrderedMap::remove` methods
1918
- `ByteSequence::equals` and `Token::equals` to easily compare type instances.
2019
- `StructuredField` extends the `Stringable` interface
20+
- `ForbiddenOperation` exception to reports invalid operation on immutable value objects.
2121

2222
### Fixed
2323

@@ -26,7 +26,7 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
2626
- **[BC Break]** `::fromAssociative`, `::fromList`, `::fromPairs` methods require iterable arguments without default value.
2727
- **[BC Break]** `Item::value` method returns the Item (returns value can be `float|int|string|bool|ByteSequence|DateTimeImmutable|Token`).
2828
- **[BC Break]** `InnerList::parameters` is no longer accessible as a public readonly property.
29-
- **[BC Break]** Modifying container instances with `ArrayAccess` modifying methods is forbidden and will trigger a `LogicException` exception.
29+
- **[BC Break]** Modifying container instances with `ArrayAccess` modifying methods is forbidden and will trigger a `ForbiddenOperation` exception.
3030

3131
### Deprecated
3232

src/Dictionary.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use ArrayAccess;
88
use DateTimeInterface;
99
use Iterator;
10-
use LogicException;
1110
use Stringable;
1211
use function array_key_exists;
1312
use function array_keys;
@@ -306,11 +305,11 @@ public function offsetGet(mixed $offset): InnerList|Value
306305

307306
public function offsetUnset(mixed $offset): void
308307
{
309-
throw new LogicException(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
308+
throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
310309
}
311310

312311
public function offsetSet(mixed $offset, mixed $value): void
313312
{
314-
throw new LogicException(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
313+
throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
315314
}
316315
}

src/ForbiddenOperation.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Bakame\Http\StructuredFields;
6+
7+
use LogicException;
8+
9+
final class ForbiddenOperation extends LogicException implements StructuredFieldError
10+
{
11+
}

src/InnerList.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use ArrayAccess;
88
use DateTimeInterface;
99
use Iterator;
10-
use LogicException;
1110
use Stringable;
1211
use function array_filter;
1312
use function array_map;
@@ -252,11 +251,11 @@ public function offsetGet(mixed $offset): Value
252251

253252
public function offsetUnset(mixed $offset): void
254253
{
255-
throw new LogicException(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
254+
throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
256255
}
257256

258257
public function offsetSet(mixed $offset, mixed $value): void
259258
{
260-
throw new LogicException(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
259+
throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
261260
}
262261
}

src/OrderedList.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use ArrayAccess;
88
use DateTimeInterface;
99
use Iterator;
10-
use LogicException;
1110
use Stringable;
1211
use function array_filter;
1312
use function array_map;
@@ -233,11 +232,11 @@ public function offsetGet(mixed $offset): InnerList|Value
233232

234233
public function offsetUnset(mixed $offset): void
235234
{
236-
throw new LogicException(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
235+
throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
237236
}
238237

239238
public function offsetSet(mixed $offset, mixed $value): void
240239
{
241-
throw new LogicException(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
240+
throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
242241
}
243242
}

src/Parameters.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use ArrayAccess;
88
use DateTimeInterface;
99
use Iterator;
10-
use LogicException;
1110
use Stringable;
1211
use function array_key_exists;
1312
use function array_keys;
@@ -329,11 +328,11 @@ public function offsetGet(mixed $offset): Value
329328

330329
public function offsetUnset(mixed $offset): void
331330
{
332-
throw new LogicException(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
331+
throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
333332
}
334333

335334
public function offsetSet(mixed $offset, mixed $value): void
336335
{
337-
throw new LogicException(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
336+
throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.');
338337
}
339338
}

0 commit comments

Comments
 (0)