masnathan/chain-php

dev-master 2017-09-29 16:44 UTC

This package is auto-updated.

Last update: 2024-11-16 16:37:15 UTC


README

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