Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Colada X Laravel Package

alexeyshockov/colada-x

colada-x is a tiny Laravel/PHP helper package by alexeyshockov. Lightweight and experimental, it offers small utilities you can drop into a project quickly. Best for tinkerers who don’t mind minimal docs, few stars, and a still-maturing API.

View on GitHub
Deep Wiki
Context7

\Colada\x()

Helper function for simplify callbacks.

Latest Stable Version Scrutinizer Code Quality Build Status

Installation

$ composer require alexeyshockov/colada-x

Usage

With ColadaX:

$activeUsers = array_filter($users, \Colada\x()->isActive());
$role = 'ADMIN';
$administrators = array_filter($users, \Colada\x()->hasRole($role));

Instead of pure PHP:

$activeUsers = array_filter($users, function ($user) {
    return $user->isActive();
});
$role = 'ADMIN';
$activeUsers = array_filter($users, function ($user) use ($role) {
    return $user->hasRole($role);
});

Useful together

Some code examples for your imagination.

Laravel 5 Collections

$activeUsers = $users->filter(\Colada\x()->isActive());

PHP Collection (schmittjoh/php-collection)

$activeUsers = $users->filter(\Colada\x()->isActive());

functional-php (lstrojny/functional-php)

The library already has partial_method function, but it's less powerful.

use Functional as F;

$activeUsers = F\select($users, \Colada\x()->isActive());

Less useful, but still

Doctrine 2 Collections (Symfony 2, Doctine 2 ORM, etc.)

// __asClosure() is needed because all Doctrine's methods accept only \Closure instances :(
$hasActiveUsers = $users->exists(\Colada\x()->isActive()->__asClosure());

Laravel 4 Collections

The same problem as described above with Doctrine.

Alernatives

If you need only the basic functionaly, take a look at invoke(), invoke_first(), invoke_if(), invoke_last(), invoker() from a great functional-php library.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
adachsoft/php-code-style