ecommit / scalar-values
Test scalar values.
Installs: 10 886
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^10
README
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.