Arrays > getNonEmptyValues() method > returns non-empty values, e.g. without "" (empty string), null or []

Arrays > getNonEmptyValuesAsString() method > returns non-empty values concatenated by given separator
This commit is contained in:
Meritoo
2019-02-22 12:49:12 +01:00
parent 79c09a26a6
commit 292c5e6d4f
11 changed files with 481 additions and 10 deletions

View File

@@ -48,7 +48,8 @@ class MimeTypesTest extends BaseTestCase
2. [Collection of elements](Collection-of-elements.md)
3. [Exceptions](Exceptions.md)
4. [Static methods](Static-methods.md)
1. [Regex](Static-methods/Regex.md)
1. [Arrays](Static-methods/Arrays.md)
2. [Regex](Static-methods/Regex.md)
5. [Value Objects](Value-Objects.md)
[‹ Back to `Readme`](../README.md)

View File

@@ -46,7 +46,8 @@ var_dump($simpleCollection->has('dolor')); // bool(true)
2. [**Collection of elements**](Collection-of-elements.md)
3. [Exceptions](Exceptions.md)
4. [Static methods](Static-methods.md)
1. [Regex](Static-methods/Regex.md)
1. [Arrays](Static-methods/Arrays.md)
2. [Regex](Static-methods/Regex.md)
5. [Value Objects](Value-Objects.md)
[‹ Back to `Readme`](../README.md)

View File

@@ -57,7 +57,8 @@ class UnknownSimpleTypeException extends UnknownTypeException
2. [Collection of elements](Collection-of-elements.md)
3. [**Exceptions**](Exceptions.md)
4. [Static methods](Static-methods.md)
1. [Regex](Static-methods/Regex.md)
1. [Arrays](Static-methods/Arrays.md)
2. [Regex](Static-methods/Regex.md)
5. [Value Objects](Value-Objects.md)
[‹ Back to `Readme`](../README.md)

View File

@@ -19,7 +19,8 @@ var_dump($firstElement); // string(5) "lorem"
2. [Collection of elements](Collection-of-elements.md)
3. [Exceptions](Exceptions.md)
4. [**Static methods**](Static-methods.md)
1. [Regex](Static-methods/Regex.md)
1. [Arrays](Static-methods/Arrays.md)
2. [Regex](Static-methods/Regex.md)
5. [Value Objects](Value-Objects.md)
[‹ Back to `Readme`](../README.md)

View File

@@ -0,0 +1,78 @@
# Meritoo Common Library
Common and useful classes, methods, exceptions etc.
# Arrays
> Useful methods related to arrays
Class: `Meritoo\Common\Utilities\Arrays`
File: `src/Utilities/Arrays.php`
### getNonEmptyValues(array $values)
> Returns non-empty values, e.g. without "" (empty string), null or []
##### Arguments
- `array $values` - The values to filter
##### Example 1
- values: `[]` (no values)
- result: `[]` (an empty array)
##### Example 2
- values: `[null, ""]` (all empty values)
- result: `[]` (an empty array)
##### Example 3
- values: `["test 1", "", 123, null, 0]`
- result: `["test 1", 123, 0]`
### getNonEmptyValuesAsString(array $values, $separator = ', ')
> Returns non-empty values concatenated by given separator
##### Arguments
- `array $values` - The values to filter
- `[string $separator]` - (optional) Separator used to implode the values. Default: ", ".
##### Example 1
- values: `[]` (no values)
- separator: default or any other string
- result: `""` (an empty string)
##### Example 2
- values: `[null, ""]` (all empty values)
- separator: default or any other string
- result: `""` (an empty string)
##### Example 3
- values: `["test 1", "", 123, null, 0]`
- separator: `", "` (default)
- result: `"test 1, 123, 0"`
##### Example 4
- values: `["test 1", "", 123, null, 0]`
- separator: `" | "`
- result: `"test 1 | 123 | 0"`
# More
1. [Base test case (with common methods and data providers)](../Base-test-case.md)
2. [Collection of elements](../Collection-of-elements.md)
3. [Exceptions](../Exceptions.md)
4. [Static methods](../Static-methods.md)
1. [**Arrays**](Arrays.md)
2. [Regex](Regex.md)
5. [Value Objects](../Value-Objects.md)
[‹ Back to `Readme`](../../README.md)

View File

@@ -4,14 +4,14 @@ Common and useful classes, methods, exceptions etc.
# Regex
*Useful methods related to regular expressions*
> Useful methods related to regular expressions
Class: `Meritoo\Common\Utilities\Regex`
File: `src/Utilities/Regex.php`
### createSlug($value)
*Returns slug for given value*
> Returns slug for given value
##### Arguments
@@ -38,7 +38,8 @@ File: `src/Utilities/Regex.php`
2. [Collection of elements](../Collection-of-elements.md)
3. [Exceptions](../Exceptions.md)
4. [Static methods](../Static-methods.md)
1. [**Regex**](../Static-methods/Regex.md)
1. [Arrays](../Static-methods/Arrays.md)
2. [**Regex**](Regex.md)
5. [Value Objects](../Value-Objects.md)
[‹ Back to `Readme`](../../README.md)

View File

@@ -48,7 +48,8 @@ New instance can be created using:
2. [Collection of elements](Collection-of-elements.md)
3. [Exceptions](Exceptions.md)
4. [Static methods](Static-methods.md)
1. [Regex](Static-methods/Regex.md)
1. [Arrays](Static-methods/Arrays.md)
2. [Regex](Static-methods/Regex.md)
5. [**Value Objects**](Value-Objects.md)
[‹ Back to `Readme`](../README.md)