https://github.com/masnathan/chain-php
Chainable native functions and more
https://github.com/masnathan/chain-php
chain chainable-methods php
Last synced: 4 months ago
JSON representation
Chainable native functions and more
- Host: GitHub
- URL: https://github.com/masnathan/chain-php
- Owner: MASNathan
- License: mit
- Created: 2017-09-28T12:07:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-29T16:44:31.000Z (over 8 years ago)
- Last Synced: 2025-12-14T22:37:20.389Z (6 months ago)
- Topics: chain, chainable-methods, php
- Language: PHP
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chain-php
Chainable native functions and more
## Usage
```php
$domain = explode('@', 'andre.r.flip@gmail.com');
$domain = end($domain);
$domain = trim($domain);
$domain = with('andre.r.flip@gmail.com')->explode('@', '$$')->end()->trim()->get();
// 'gmail.com'
```
or
```php
$key = with('some.service.3rdparty.integration')
->explode('.', '!!')
->array_map(function ($value) {
return $value == '3rdparty' ? 'local' : $value;
}, '!!')
->implode('.', '!!')
->get();
// 'some.service.local.integration'
```
Inspired by [Sebastiaan Luca Pipe item](https://blog.sebastiaanluca.com/enabling-php-method-chaining-with-a-makeshift-pipe-operator)