PLZ: A handy PHP library for lazy programmers
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • amekusa
    • plz
  • PHP

Classes

  • alt
  • arr
  • constant
  • dom
  • fn
  • num
  • obj
  • op
  • path
  • str
  • sys
  • T
  • type
  • xml

Exceptions

  • ErrorException

Class op

Operator utilities

To get started, place the following line around top of your code.

use amekusa\plz\op;
Abstract
Namespace: amekusa\plz
Located at op.php

Methods summary

public static boolean
# eq( mixed $X, mixed $Y )

Returns whether or not $X equals $Y

Returns whether or not $X equals $Y

Parameters

$X
$Y

Returns

boolean
public static boolean
# any( mixed[*] $Conditions )

Returns whether any one of conditions supplied is truthy

Returns whether any one of conditions supplied is truthy

If only 1 argument is passed and it is iterable, checks whether any one of its elements is truthy.

Parameters

$Conditions

Returns

boolean

Example

Demonstration

$var1 = 0;        // Falsy
$var2 = null;     // Falsy
$var3 = 'string'; // Truthy
var_dump( op::any($var1, $var2)        );
var_dump( op::any($var1, $var2, $var3) );
bool(false)
bool(true)

Checking iterable elements

$var1 = array (
  0,       // Falsy
  null,    // Falsy
  'string' // Truthy
);
$var2 = array (
  0,       // Falsy
  null,    // Falsy
  false    // Falsy
);
var_dump( op::any($var1) );
var_dump( op::any($var2) );
bool(true)
bool(false)

public static boolean
# all( mixed[*] $Conditions )

Returns whether all of conditions supplied is truthy

Returns whether all of conditions supplied is truthy

If only 1 argument is passed and it is iterable, checks whether all of its elements is truthy.

Parameters

$Conditions

Returns

boolean

Example

Demonstration

$var1 = 1;    // Truthy
$var2 = true; // Truthy
$var3 = null; // Falsy
var_dump( op::all($var1, $var2)        );
var_dump( op::all($var1, $var2, $var3) );
bool(true)
bool(false)

Checking iterable elements

$var1 = array (
  1,       // Truthy
  true,    // Truthy
  null     // Falsy
);
$var2 = array (
  1,       // Truthy
  true,    // Truthy
  'string' // Truthy
);
var_dump( op::all($var1) );
var_dump( op::all($var2) );
bool(false)
bool(true)

PLZ: A handy PHP library for lazy programmers API documentation generated by ApiGen