PHP code example of sharoff45 / library-support

1. Go to this page and download the library: Download sharoff45/library-support library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sharoff45 / library-support example snippets


use Sharoff45\Library\Support\IsNotEmptyArray;
use Sharoff45\Library\Support\IsNotEmptyString;
use Sharoff45\Library\Support\IsNotNull;
use Sharoff45\Library\Support\IsNull;
use Sharoff45\Library\Support\IsNullOrEmptyString;
use Sharoff45\Library\Support\IsEmptyArray;

// ...
$result = array_filter($list, new IsNotEmptyArray());

//...
$result = array_filter($list, new IsNotEmptyString());

// ...
$result = array_filter($list, new IsNotNull());

//...
$result = array_filter($list, new IsNull());

// ...
$result = array_filter($list, new IsNullOrEmptyString());

// ...
$result = array_filter($list, new IsEmptyArray());

use function Sharoff45\Library\Support\isEmptyArray;
use function Sharoff45\Library\Support\isNotEmptyArray;
use function Sharoff45\Library\Support\isNotEmptyString;
use function Sharoff45\Library\Support\isNotNull;
use function Sharoff45\Library\Support\isNull;
use function Sharoff45\Library\Support\isNullOrEmptyString;
use function Sharoff45\Library\Support\isEmptyArrayFilter;
use function Sharoff45\Library\Support\isNotEmptyArrayFilter;

if (isEmptyArray($value)) {}

if (isNotEmptyArray($value)) {}

if (isNotEmptyString($value)) {}

if (isNotNull($value)) {}

if (isNull($value)) {}

if (isNullOrEmptyString($value)) {}

if (isEmptyArrayFilter($array)) {}

if (isNotEmptyArrayFilter($array)) {}

    class A
    {
    	private $a = 1;
    	protected $b = 2;
    	public $c = 3;
    }

    var_dump(objectToArray(new A));

$isBelowThreshold = function ($value) {
    return $value < 40;
};

$items = [1, 30, 39, 29, 10, 13];

var_dump(all($items, $isBelowThreshold));