https://github.com/nejcc/php-custom-types
Php package that provides custom data types like i8, u8, i32, u32, f32, and more.
https://github.com/nejcc/php-custom-types
laravel library mit-license package php8 unittest
Last synced: 3 months ago
JSON representation
Php package that provides custom data types like i8, u8, i32, u32, f32, and more.
- Host: GitHub
- URL: https://github.com/nejcc/php-custom-types
- Owner: Nejcc
- License: mit
- Created: 2024-09-09T21:00:22.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-10T06:27:25.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T08:40:54.556Z (over 1 year ago)
- Topics: laravel, library, mit-license, package, php8, unittest
- Language: PHP
- Homepage:
- Size: 88.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Custom Types
[](https://packagist.org/packages/nejcc/php-custom-types)
[](https://packagist.org/packages/nejcc/php-custom-types)
[](https://packagist.org/packages/nejcc/php-custom-types)
**Nejcc/php-custom-types** is a Laravel package that provides custom data types like `i8`, `u8`, `i32`, `u32`, `f32`, and more. These custom types help enforce data integrity, memory efficiency, and validation constraints in your Laravel applications.
## Features
- **Custom Integer Types**: `i8`, `u8`, `i32`, `u32`
- **Custom Floating Point Type**: `f32`
- **Custom String Type**: `Utf8String`
- **Tuple and Array Types**: `Pair`, `FixedArray`
- **Easy Integration**: Designed to work seamlessly with Laravel.
- **PHP 8.3 Compatibility**: Leverages the latest PHP features for performance and security.
## Installation
To install the package, use Composer:
```bash
composer require nejcc/php-custom-types
```
## Tree
```
CustomTypes
├── Scalar Types
│ ├── Integer Types
│ │ ├── Signed Integers
│ │ │ ├── i8 (8-bit signed)
│ │ │ ├── i16 (16-bit signed)
│ │ │ ├── i32 (32-bit signed)
│ │ │ ├── i64 (64-bit signed)
│ │ │ └── i128 (128-bit signed)
│ │ └── Unsigned Integers
│ │ ├── u8 (8-bit unsigned)
│ │ ├── u16 (16-bit unsigned)
│ │ ├── u32 (32-bit unsigned)
│ │ ├── u64 (64-bit unsigned)
│ │ └── u128 (128-bit unsigned)
│ ├── Floating-Point Types
│ │ ├── f16 (16-bit floating-point)
│ │ ├── f32 (32-bit floating-point)
│ │ ├── f64 (64-bit floating-point)
│ │ └── f128 (128-bit floating-point)
│ ├── Character Type
│ │ └── Char (Single Unicode character)
│ └── Boolean Type
│ └── Bool (Boolean, true or false)
├── Compound Types
│ ├── Tuple
│ │ └── Tuple (Fixed-size collection of heterogeneous values)
│ └── FixedArray
│ └── FixedArray (Fixed-size collection of homogeneous values)
├── String Types
│ ├── StrSlice (Immutable string slice)
│ └── OwnedString (Owned, mutable string)
├── Collection Types
│ ├── Vec (Growable array type)
│ ├── HashMap (Key-value store)
│ └── HashSet (Unordered collection of unique values)
├── Custom Types
│ ├── Structs
│ │ └── ExampleStruct (Custom user-defined data structures)
│ └── Enums
│ └── ExampleEnum (Custom enumerations)
├── Smart Pointer Types
│ ├── Box (Single ownership heap allocation)
│ ├── Rc (Reference counted pointer)
│ ├── RefCell (Single-threaded interior mutability)
│ └── Mutex (Thread-safe interior mutability)
└── Other Types
├── Unit (Represents an empty value or no value)
└── PhantomData (Marker for unused generic type parameters)
```
## Usage
### Custom Integer Types
#### `i32` (32-bit Signed Integer)
```php
use Nejcc\CustomTypes\ScalarTypes\Integers\Signed\i32;
$number = new i32(123456);
echo $number->getValue(); // Output: 123456
```
## Running Tests
To run the unit tests for this package, ensure that you have PHPUnit installed and run:
```bash
./vendor/bin/phpunit
```
## License
This package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).