Skip to content

Commit 085a2b4

Browse files
committed
add value to the Caster
1 parent c14f832 commit 085a2b4

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Check MD [online][check-online].
99

1010
## [unreleased]
1111

12+
## [1.1.0] - 2021-05-25
13+
14+
### Added
15+
16+
- Add a method `value` to the interface `Caster`
17+
1218
## [1.0.0] - 2021-04-28
1319

1420
### Changed

src/Caster/AbstractCasting.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,9 @@ protected static function emptyJsonStruct(): ?string
196196
{
197197
return self::EMPTY_JSON_OBJECT;
198198
}
199+
200+
public function value(): mixed
201+
{
202+
return static::castToDatabase($this);
203+
}
199204
}

src/Caster/AbstractCastingCollection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,9 @@ public function count(): int
308308
{
309309
return count($this->items);
310310
}
311+
312+
public function value(): mixed
313+
{
314+
return static::castToDatabase($this);
315+
}
311316
}

src/Caster/Caster.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ public static function castToDatabase($value): ?string;
1111
public function castFromDatabase(?string $value);
1212

1313
public static function isEquivalent($value, $original): bool;
14+
15+
public function value(): mixed;
1416
}

src/Caster/PgArray.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ public static function isEquivalent($value, $original): bool
2727
{
2828
return $value === $original;
2929
}
30+
31+
public function value(): mixed
32+
{
33+
return static::castToDatabase($this);
34+
}
3035
}

0 commit comments

Comments
 (0)