Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation and Code Organization Improvements #23

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 101 additions & 2 deletions src/Strictus.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,96 +17,195 @@

final class Strictus
{
/**
* Create a StrictusString object.
*
* @param mixed $string The value to be wrapped in a StrictusString object.
* @param bool $nullable Indicates if the StrictusString object can be null.
*/
public static function string(mixed $string, bool $nullable = false): StrictusString
{
return new StrictusString($string, $nullable);
}

/**
* Create a nullable StrictusString object.
*
* @param mixed $string The value to be wrapped in a StrictusString object.
*/
public static function nullableString(mixed $string): StrictusString
{
return new StrictusString($string, true);
}

/**
* Create a StrictusInteger object.
*
* @param mixed $integer The value to be wrapped in a StrictusInteger object.
* @param bool $nullable Indicates if the StrictusInteger object can be null.
*/
public static function int(mixed $integer, bool $nullable = false): StrictusInteger
{
return new StrictusInteger($integer, $nullable);
}

/**
* Create a nullable StrictusInteger object.
*
* @param mixed $integer The value to be wrapped in a StrictusInteger object.
*/
public static function nullableInt(mixed $integer): StrictusInteger
{
return new StrictusInteger($integer, true);
}

/**
* Create a StrictusFloat object.
*
* @param mixed $float The value to be wrapped in a StrictusFloat object.
* @param bool $nullable Indicates if the StrictusFloat object can be null.
*/
public static function float(mixed $float, bool $nullable = false): StrictusFloat
{
return new StrictusFloat($float, $nullable);
}

/**
* Create a nullable StrictusFloat object.
*
* @param mixed $float The value to be wrapped in a StrictusFloat object.
*/
public static function nullableFloat(mixed $float): StrictusFloat
{
return new StrictusFloat($float, true);
}

/**
* Create a StrictusBoolean object.
*
* @param mixed $boolean The value to be wrapped in a StrictusBoolean object.
* @param bool $nullable Indicates if the StrictusBoolean object can be null.
*/
public static function bool(mixed $boolean, bool $nullable = false): StrictusBoolean
{
return new StrictusBoolean($boolean, $nullable);
}

/**
* Create a nullable StrictusBoolean object.
*
* @param mixed $boolean The value to be wrapped in a StrictusBoolean object.
*/
public static function nullableBool(mixed $boolean): StrictusBoolean
{
return new StrictusBoolean($boolean, true);
}

/**
* Create a StrictusArray object.
*
* @param mixed $array The value to be wrapped in a StrictusArray object.
* @param bool $nullable Indicates if the StrictusArray object can be null.
*/
public static function array(mixed $array, bool $nullable = false): StrictusArray
{
return new StrictusArray($array, $nullable);
}

/**
* Create a nullable StrictusArray object.
*
* @param mixed $array The value to be wrapped in a StrictusArray object.
*/
public static function nullableArray(mixed $array): StrictusArray
{
return new StrictusArray($array, true);
}

/**
* Create a StrictusObject object.
*
* @param mixed $object The value to be wrapped in a StrictusObject object.
* @param bool $nullable Indicates if the StrictusObject object can be null.
*/
public static function object(mixed $object, bool $nullable = false): StrictusObject
{
return new StrictusObject($object, $nullable);
}

/**
* Create a nullable StrictusObject object.
*
* @param mixed $object The value to be wrapped in a StrictusObject object.
*/
public static function nullableObject(mixed $object): StrictusObject
{
return new StrictusObject($object, true);
}

/**
* Create a StrictusInstance object.
*
* @param string $instanceType The type of the instance.
* @param mixed $instance The value to be wrapped in a StrictusInstance object.
* @param bool $nullable Indicates if the StrictusInstance object can be null.
*/
public static function instance(string $instanceType, mixed $instance, bool $nullable = false): StrictusInstance
{
return new StrictusInstance($instanceType, $instance, $nullable);
}

/**
* Create a nullable StrictusInstance object.
*
* @param string $instanceType The type of the instance.
* @param mixed $instance The value to be wrapped in a StrictusInstance object.
*/
public static function nullableInstance(string $instanceType, mixed $instance): StrictusInstance
{
return new StrictusInstance($instanceType, $instance, true);
}

/**
* Create a StrictusEnum object.
*
* @param string $enumType The type of the enum.
* @param mixed $enum The value to be wrapped in a StrictusEnum object.
* @param bool $nullable Indicates if the StrictusEnum object can be null.
*/
public static function enum(string $enumType, mixed $enum, bool $nullable = false): StrictusEnum
{
return new StrictusEnum($enumType, $enum, $nullable);
}

/**
* Create a nullable StrictusEnum object.
*
* @param string $enumType The type of the enum.
* @param mixed $enum The value to be wrapped in a StrictusEnum object.
*/
public static function nullableEnum(string $enumType, mixed $enum): StrictusEnum
{
return new StrictusEnum($enumType, $enum, true);
}

/**
* @param array<int, Type> $types
* Create a StrictusUnion object.
*
* @param Type[] $types The types included in the union.
* @param mixed $value The value to be wrapped in a StrictusUnion object.
* @param bool $nullable Indicates if the StrictusUnion object can be null.
*/
public static function union(array $types, mixed $value, bool $nullable = false): StrictusUnion
{
return new StrictusUnion($types, $value, $nullable);
}

/**
* @param array<int, Type> $types
* Create a nullable StrictusUnion object.
*
* @param Type[] $types The types included in the union.
* @param mixed $value The value to be wrapped in a StrictusUnion object.
*/
public static function nullableUnion(array $types, mixed $value): StrictusUnion
{
Expand Down