Simple libary for functional programing paradigm with arrays.

Overview

rodrigodornelles/php-array-lib

version license quality coverage building

simple libary for functional programing paradigm with arrays

Features

  • Test driven development style (TDD)
  • PHP version compatibility 5.4 at 8.2
  • Make your code cleaner and more readable
  • Adds new methods to manipulate arrays (Inspired by ruby, js and other langs)

How to Use

use ArrayCreate;                                  # if you using namespaces

$myNewArray = ArrayCreate::from($myOriginalArray) # instantiate pipeline class
  ->map(someItemFunction)                         # first function to iterate on each item
  ->map(anotherItemFunction)                      # next function to iterate on each item
  ->filter(anotherItemFunction2)                  # next function to filter on each item
  ->construct();                                  # returns new array

Examples

side by side comparison

Make an algorithm that sorts an array, removes the numbers not divisible by 3, and shows the result of each multiplied by 2 and separated by commas.

Libary
Functional
Native
Functional
Structured
libary functional example native functional example structured example

Installation

With Composer

The preferred way to install this extension is through composer.

Either run

$ composer require dynamikaweb/php-brazil-info "~1.0.0"

or add

"rodrigodornelles/php-array-lib": "~1.0.0"

to the require section of your composer.json file.

Without Composer

Step 1

Download libary in https://github.com/RodrigoDornelles/php-array-lib/releases

Step 2

Extract the file into your libraries folder

Step 3

Import the main class

 

require_once __DIR__.'/path/to/my/libaries/php-array-lib/src/ArrayCreate.php';
You might also like...
N2Web turns your Notion HTML export into a fully functional static website
N2Web turns your Notion HTML export into a fully functional static website

Notion2Web N2Web turns your Notion HTML export into a fully functional static website. What is Notion? Notion is an online tool. But I can't tell you

WARNING! This software is currently non-functional. - A system which makes installing Jexactyl far, far easier.
WARNING! This software is currently non-functional. - A system which makes installing Jexactyl far, far easier.

Jexactyl Assistant A system which makes installing Jexactyl far, far easier. WARNING 🚧 This software is currently in heavy alpha testing and WILL NOT

Sitepackage for TYPO3 CMS that adheres to the recommended standards, maps all conceivable functional areas and contains examples for common use cases.

TYPO3 CMS Sitepackage This sitepackage sticks as closely as possible to the recommended standard and maps all conceivable functional areas. There are

Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers
Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers

Magento 2 SMTP Extension - Gmail, G Suite, Amazon SES, Office 365, Mailgun, SendGrid, Mandrill and other SMTP servers. For Magento 2.0.x, 2.1.x, 2.2.x

Simple PHP Pages - A simple puristic PHP Website Boilerplate
Simple PHP Pages - A simple puristic PHP Website Boilerplate

Simple PHP Pages - A simple puristic PHP Website Boilerplate 🚀 Hey! This project provides simple and basic concepts for PHP pages. It includes ideas

Sslurp is a simple library which aims to make properly dealing with SSL in PHP suck less.

Sslurp v1.0 by Evan Coury Introduction Dealing with SSL properly in PHP is a pain in the ass and completely insecure by default. Sslurp aims to make i

Currency is a simple PHP library for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangerate.host

Currency Currency is a simple PHP library for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangera

Simple IT Documentation Solution for MSPs

SimpleMSPDoc RC 1.0 I wasn't happy with what other IT documention software had. I felt they over complicated things and required so much clicky clicky

Simple customizable captcha script for bot prevention in php language.

phpCaptcha Simple customizable captcha script for bot prevention in php language. Usage ?php session_start(); $status = ""; if ($_SESSION['captcha']

Comments
  • fix php version in composer

    fix php version in composer

    semantic version is ambiguous, and the pattern I intend to follow is to add each minor version of php separately. (backward composer compatibility)

    • change ^5.4|^5.5|^5.6|^7.0|^7.1|^7.2|^7.3|^7.4|^8.0|^8.1|^8.2
    • to ~5.4.0|~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.0.0|~8.1.0|~8.2.0
    opened by RodrigoDornelles 0
  • automatic tests worflow

    automatic tests worflow

    • full test and fast test suites
    • test php versions 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 8.0, 8.1, 8.2
    • coverage tests and report to codacy

    close #1

    opened by RodrigoDornelles 0
  • to do list

    to do list

    • [ ] array_change_key_case
    • [ ] array_chunk
    • [ ] array_column
    • [ ] array_combine
    • [ ] array_count_values
    • [ ] array_diff_assoc
    • [ ] array_diff_key
    • [ ] array_diff_uassoc
    • [ ] array_diff_ukey
    • [ ] array_diff
    • [ ] array_fill_keys
    • [ ] array_fill
    • [X] array_filter
    • [X] array_flip
    • [ ] array_intersect_assoc
    • [ ] array_intersect_key
    • [ ] array_intersect_uassoc
    • [ ] array_intersect_ukey
    • [ ] array_intersect
    • [ ] array_is_list
    • [ ] array_key_exists
    • [ ] array_key_first
    • [ ] array_key_last
    • [ ] array_keys
    • [X] array_map
    • [ ] array_merge_recursive
    • [ ] array_merge
    • [ ] array_multisort
    • [ ] array_pad
    • [ ] array_pop
    • [ ] array_product
    • [ ] array_push
    • [ ] array_rand
    • [ ] array_reduce
    • [ ] array_replace_recursive
    • [ ] array_replace
    • [ ] array_reverse
    • [ ] array_search
    • [ ] array_shift
    • [ ] array_slice
    • [ ] array_splice
    • [ ] array_sum
    • [ ] array_udiff_assoc
    • [ ] array_udiff_uassoc
    • [ ] array_udiff
    • [ ] array_uintersect_assoc
    • [ ] array_uintersect_uassoc
    • [ ] array_uintersect
    • [ ] array_unique
    • [ ] array_unshift
    • [ ] array_values
    • [ ] array_walk_recursive
    • [ ] array_walk
    good first issue 
    opened by RodrigoDornelles 0
Releases(1.0.0)
  • 1.0.0(Apr 17, 2022)

    changelogs

    • added method construct
    • added method filter
    • added method first
    • added method flip
    • added method from
    • added method join
    • added method last
    • added method map
    • added method sort
    • added support php 5.4
    • added support php 5.5
    • added support php 5.6
    • added support php 7.0
    • added support php 7.1
    • added support php 7.2
    • added support php 7.3
    • added support php 7.4
    • added support php 8.0
    • added support php 8.1
    • added support php 8.2
    • fully developed in TDD
    • started with 100% tests covered
    Source code(tar.gz)
    Source code(zip)
Owner
null
This package was created to provide simple way to manipulate arrays in PHP

PHP Collections This package was created to provide simple way to manipulate arrays in PHP. The package was inspired by the Laravel Collections.

Wojciech Mleczek 13 Jul 26, 2021
Dobren Dragojević 6 Jun 11, 2023
A simple functional programming library for PHP

bingo-functional A simple functional programming library for PHP. Requirement(s) PHP 7 or higher Rationale PHP, a language not commonly associated wit

Lochemem Bruno Michael 52 Sep 28, 2022
Make your PHP arrays sweet'n'safe

Mess We face a few problems in our PHP projects Illogical type casting (PHP's native implementation is way too "smart") Pointless casts like array =>

Artem Zakirullin 192 Nov 28, 2022
🏆 Learn You PHP! - An introduction to PHP's core features: i/o, http, arrays, exceptions and so on.

Learn You PHP! The very first PHP School workshop. A revolutionary new way to learn PHP Bring your imagination to life in an open learning eco-system

PHP School 311 Dec 30, 2022
Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project.

ConfigStruct Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project. It

EndermanbugZJFC 9 Aug 22, 2022
Safely break down arrays or objects, and put them back together in new shapes.

traverse/reshape traverse() and reshape() are companion functions that safely break down arrays or objects and put them back together in new shapes. t

Alley Interactive 2 Aug 4, 2022
PHP functions that help you validate structure of complex nested PHP arrays.

PHP functions that help you validate structure of complex nested PHP arrays.

cd rubin 7 May 22, 2022
A collection of type-safe functional data structures

lamphpda A collection of type-safe functional data structures Aim The aim of this library is to provide a collection of functional data structures in

Marco Perone 99 Nov 11, 2022
Small library providing some functional programming tools for PHP, based on Rambda

Functional library for PHP. Features: set of useful functions helpful in functional programming all functions are automatically curried every array ca

Wojciech Nawalaniec 5 Jun 16, 2022