Coder Social home page Coder Social logo

faelv / isx Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 20 KB

ISX is a set of functions to ease the usage of PHP's is_* functions on multiple variables

Home Page: https://packagist.org/packages/faelv/isx

License: ISC License

PHP 100.00%
composer functions helper library php

isx's Introduction

Isx

ISX is a set of functions to ease the usage of PHP's is_* functions (like is_null or empty) on multiple variables at the same time without the need to repeat the function name for each value.

For example, instead of writing:

if (is_null($a) || is_null($b) || is_null($c)) {

You can simple do this:

if (is_null_any($a, $b, $c)) {

Installing

Using Composer just run:

composer require faelv/isx

DO NOT FORGET TO IMPORT THE FUNCTIONS YOU WANT TO USE!

<?php

use function Isx\is_empty_all;
use function Isx\{is_null_all, is_any};

Available Functions

is_null_all

Returns true if all values are null, false otherwise

is_null_any

Returns true if at least one value is null, false otherwise

is_false_all

Returns true if all values are false, false otherwise

is_false_any

Returns true if at least one value is false, false otherwise

is_true_all

Returns true if all values are true, false otherwise

is_true_any

Returns true if at least one value is true, false otherwise

is_empty_all

Returns true if all values are empty, false otherwise

is_empty_any

Returns true if at least one value is empty, false otherwise

is_all

Returns true if a callback function (which receives one parameter) also returns true for all values, false otherwise [see usage below]

is_any

Returns true if a callback function (which receives one parameter) also returns true for at least one value, false otherwise [see usage below]

Using is_all and is_any

With is_all and is_any you can use any function to test your variables:

is_all('is_int', 1, 2, 3)
is_any(fn($value) => strlen($value) > 3, ...$strArray)

isx's People

Contributors

faelv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.