Skip to content

Commit 0cdd3cc

Browse files
committed
Add toString functionality to integer and float classes, refine type interfaces, and adjust accessibility of convertMixedToString.
1 parent 0b95c5a commit 0cdd3cc

File tree

14 files changed

+85
-25
lines changed

14 files changed

+85
-25
lines changed

src/Abstract/AbstractType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*
4040
* @throws TypeException
4141
*/
42-
public static function convertMixedToString(mixed $value): string
42+
protected static function convertMixedToString(mixed $value): string
4343
{
4444
if (is_scalar($value) || $value === null) {
4545
return (string) $value;

src/Abstract/Float/FloatType.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,4 @@ protected static function assertFloatString(string $value): void
3737
throw new FloatTypeException(sprintf('String "%s" has no valid float value', $value));
3838
}
3939
}
40-
41-
public function toString(): string
42-
{
43-
return (string) $this->value();
44-
}
45-
46-
public function __toString(): string
47-
{
48-
return $this->toString();
49-
}
5040
}

src/Abstract/Float/FloatTypeInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,5 @@ public function value(): float;
2424

2525
public static function fromFloat(float $value): static;
2626

27-
public function toString(): string;
28-
2927
public static function tryFromString(string $value): static|Undefined;
3028
}

src/Abstract/Integer/IntType.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,4 @@ protected static function assertIntegerString(string $value): void
3939
throw new IntegerTypeException(sprintf('String "%s" has no valid strict integer value', $value));
4040
}
4141
}
42-
43-
public function toString(): string
44-
{
45-
return (string) $this->value();
46-
}
47-
48-
public function __toString(): string
49-
{
50-
return $this->toString();
51-
}
5242
}

src/Abstract/Integer/IntTypeInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,5 @@ public function value(): int;
2424

2525
public static function fromInt(int $value): static;
2626

27-
public static function tryFromString(string $value): static|Undefined;
28-
2927
public static function tryFromInt(int $value): static|Undefined;
3028
}

src/Float/FloatNonNegative.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,14 @@ public function jsonSerialize(): float
9797
{
9898
return $this->value();
9999
}
100+
101+
public function toString(): string
102+
{
103+
return (string) $this->value();
104+
}
105+
106+
public function __toString(): string
107+
{
108+
return $this->toString();
109+
}
100110
}

src/Float/FloatPositive.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,14 @@ public function jsonSerialize(): float
9595
{
9696
return $this->value();
9797
}
98+
99+
public function toString(): string
100+
{
101+
return (string) $this->value();
102+
}
103+
104+
public function __toString(): string
105+
{
106+
return $this->toString();
107+
}
98108
}

src/Float/FloatStandard.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,14 @@ public function jsonSerialize(): float
7070
{
7171
return $this->value();
7272
}
73+
74+
public function toString(): string
75+
{
76+
return (string) $this->value();
77+
}
78+
79+
public function __toString(): string
80+
{
81+
return $this->toString();
82+
}
7383
}

src/Integer/IntegerNonNegative.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,14 @@ public function jsonSerialize(): int
9090
{
9191
return $this->value();
9292
}
93+
94+
public function toString(): string
95+
{
96+
return (string) $this->value();
97+
}
98+
99+
public function __toString(): string
100+
{
101+
return $this->toString();
102+
}
93103
}

src/Integer/IntegerPositive.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,14 @@ public function jsonSerialize(): int
9090
{
9191
return $this->value();
9292
}
93+
94+
public function toString(): string
95+
{
96+
return (string) $this->value();
97+
}
98+
99+
public function __toString(): string
100+
{
101+
return $this->toString();
102+
}
93103
}

0 commit comments

Comments
 (0)