ecommit/scalar-values

Test scalar values.

v1.1.0 2023-01-08 11:49 UTC

This package is auto-updated.

Last update: 2024-10-30 14:42:24 UTC


README

Tests

Installation

To install scalar-values with Composer just run :

$ composer require ecommit/scalar-values

Usage

Test if an array contains only scalar values :

use Ecommit\ScalarValues\ScalarValues;

$array = ['str1', 2, 3];
if (ScalarValues::containsOnlyScalarValues($array)) { //True
    //...
} else {
    //...
}

$array = ['str1', ['tab'], 3];
if (ScalarValues::containsOnlyScalarValues($array)) { //False
    //...
} else {
    //...
}

Returns the input array after deleting all non-scalar values (on root):

use Ecommit\ScalarValues\ScalarValues;

$array = ['str1', ['tab'], 3];
$newArray = ScalarValues::filterScalarValues($array); //[0 => 'str1', 2 => 3]

License

This librairy is under the MIT license. See the complete license in LICENSE file.