Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/israelalagbe/php-custom-types
Custom types for PHP similar to Array and String in JavaScript
https://github.com/israelalagbe/php-custom-types
Last synced: about 2 months ago
JSON representation
Custom types for PHP similar to Array and String in JavaScript
- Host: GitHub
- URL: https://github.com/israelalagbe/php-custom-types
- Owner: israelalagbe
- License: mit
- Created: 2021-03-18T08:10:40.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-16T17:16:25.000Z (10 months ago)
- Last Synced: 2024-11-22T17:09:45.746Z (about 2 months ago)
- Language: PHP
- Homepage:
- Size: 39.1 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Custom PHP Types
This package holds some custom PHP types such as Array and String. It provides functionalities similar to array and string in Javascript.## Installation
Require this package```sh
composer require israelalagbe/php-custom-types
```
## Array Types
### Basic Usage
You can use it the following way```php
use IsraelAlagbe\CustomTypes\_Array;
$items = new _Array([1,2]); // or _Array(1, 2)
$items->push(4); // [1,2,4]
$items->map(function($item) {
return $item * 2;
}); // [2, 4, 8]echo $items;
//To get the original array, you can use
print_r($items->toArray()); // [2, 4, 8]```
## Testing
If you forked this package, you can test using the command below.```sh
composer test
```License
----MIT