An open API service indexing awesome lists of open source software.

https://github.com/e-commit/scalar-values

Test scalar values
https://github.com/e-commit/scalar-values

php scalar-values

Last synced: about 1 month ago
JSON representation

Test scalar values

Awesome Lists containing this project

README

        

# Scalar Values Tools

![Tests](https://github.com/e-commit/scalar-values/workflows/Tests/badge.svg)

## Installation ##

To install scalar-values with Composer just run :

```bash
$ composer require ecommit/scalar-values
```

## Usage ##

Test if an array contains only scalar values :

```php
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):

```php
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.