Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
🎨 Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
siguici committed Sep 27, 2024
1 parent 4bd8ad4 commit 7ad3d62
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 97 deletions.
18 changes: 9 additions & 9 deletions src/Concerns/AsBool.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ trait AsBool
{
use AsScalar;

public function __invoke(mixed $value = null): bool
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}

abstract public function get(): bool;

/**
Expand All @@ -35,15 +44,6 @@ public static function of(mixed $value): self
));
}

public function __invoke(mixed $value = null): bool
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}

public function isTrue(): bool
{
return $this->get();
Expand Down
18 changes: 9 additions & 9 deletions src/Concerns/AsFloat.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ trait AsFloat
{
use AsNumber;

public function __invoke(mixed $value = null): float
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}

abstract public function get(): float;

/**
Expand All @@ -34,13 +43,4 @@ public static function of(mixed $value): self
get_debug_type($value),
));
}

public function __invoke(mixed $value = null): float
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}
}
18 changes: 9 additions & 9 deletions src/Concerns/AsInt.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ trait AsInt
{
use AsNumber;

public function __invoke(mixed $value = null): int
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}

abstract public function get(): int;

/**
Expand All @@ -34,13 +43,4 @@ public static function of(mixed $value): self
get_debug_type($value),
));
}

public function __invoke(mixed $value = null): int
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}
}
18 changes: 9 additions & 9 deletions src/Concerns/AsMixed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@

trait AsMixed
{
public function __invoke(mixed $value = null): mixed
{
if ($value !== null) {
static::of($value)->get();
}

return $this->get();
}

abstract public function get(): mixed;

public static function of(mixed $value): self
Expand All @@ -31,13 +40,4 @@ public function to(string $type): MixedType
{
return $type::of($this->get());
}

public function __invoke(mixed $value = null): mixed
{
if ($value !== null) {
static::of($value)->get();
}

return $this->get();
}
}
18 changes: 9 additions & 9 deletions src/Concerns/AsNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ trait AsNumber
{
use AsNumeric;

public function __invoke(mixed $value = null): int|float
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}

abstract public function get(): int|float;

/**
Expand All @@ -34,13 +43,4 @@ public static function of(mixed $value): self
get_debug_type($value),
));
}

public function __invoke(mixed $value = null): int|float
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}
}
18 changes: 9 additions & 9 deletions src/Concerns/AsNumeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ trait AsNumeric
{
use AsScalar;

public function __invoke(mixed $value = null): int|float|string
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}

abstract public function get(): int|float|string;

/**
Expand All @@ -34,13 +43,4 @@ public static function of(mixed $value): self
get_debug_type($value),
));
}

public function __invoke(mixed $value = null): int|float|string
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}
}
20 changes: 10 additions & 10 deletions src/Concerns/AsScalar.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ trait AsScalar
public function __toString(): string
{
/** @psalm-suppress RedundantCast */
return (string) $this->get();
return $this->get();
}

public function __invoke(mixed $value = null): bool|int|float|string
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}

abstract public function get(): bool|int|float|string;
Expand Down Expand Up @@ -41,13 +50,4 @@ public static function of(mixed $value): self
get_debug_type($value),
));
}

public function __invoke(mixed $value = null): bool|int|float|string
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}
}
18 changes: 9 additions & 9 deletions src/Concerns/AsString.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ trait AsString
{
use AsScalar;

public function __invoke(mixed $value = null): string
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}

/**
* @throws \InvalidArgumentException If the value is not a string.
*/
Expand All @@ -32,13 +41,4 @@ public static function of(mixed $value): self
get_debug_type($value),
));
}

public function __invoke(mixed $value = null): string
{
if ($value !== null) {
return static::of($value)->get();
}

return $this->get();
}
}
12 changes: 2 additions & 10 deletions src/Types/BoolType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

interface BoolType extends ScalarType
{
public function __invoke(mixed $value = null): bool;

public function get(): bool;

public function isTrue(): bool;
Expand All @@ -15,14 +17,4 @@ public function isFalse(): bool;
public function toTrue(): self;

public function toFalse(): self;

public static function isTruthy(bool $value): bool;

public static function isFalsy(bool $value): bool;

public static function truthify(mixed $value): self;

public static function falsify(mixed $value): self;

public function __invoke(mixed $value = null): bool;
}
4 changes: 2 additions & 2 deletions src/Types/FloatType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

interface FloatType extends NumberType
{
public function get(): float;

public function __invoke(mixed $value = null): float;

public function get(): float;
}
4 changes: 2 additions & 2 deletions src/Types/IntType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

interface IntType extends NumberType
{
public function get(): int;

public function __invoke(mixed $value = null): int;

public function get(): int;
}
4 changes: 2 additions & 2 deletions src/Types/MixedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

interface MixedType
{
public function __invoke(mixed $value = null): mixed;

public function get(): mixed;

public static function of(mixed $value): self;

public function __invoke(mixed $value = null): mixed;
}
4 changes: 2 additions & 2 deletions src/Types/NumberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

interface NumberType extends NumericType
{
public function get(): int|float;

public function __invoke(mixed $value = null): int|float;

public function get(): int|float;
}
4 changes: 2 additions & 2 deletions src/Types/NumericType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

interface NumericType extends ScalarType
{
public function get(): int|float|string;

public function __invoke(mixed $value = null): int|float|string;

public function get(): int|float|string;
}
4 changes: 2 additions & 2 deletions src/Types/ScalarType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

interface ScalarType extends \Stringable, MixedType
{
public function get(): bool|int|float|string;

public function __invoke(mixed $value = null): bool|int|float|string;

public function get(): bool|int|float|string;
}
4 changes: 2 additions & 2 deletions src/Types/StringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

interface StringType extends ScalarType
{
public function get(): string;

public function __invoke(mixed $value = null): string;

public function get(): string;
}

0 comments on commit 7ad3d62

Please sign in to comment.