MASNathan / chain-php

Chainable native functions and more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chain-php

Chainable native functions and more

Usage

$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

$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

About

Chainable native functions and more

License:MIT License


Languages

Language:PHP 100.0%