Skip to content

Latest commit

 

History

History
109 lines (67 loc) · 2.04 KB

Arrays.md

File metadata and controls

109 lines (67 loc) · 2.04 KB

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

containsEmptyStringsOnly(array): bool

Returns information if given array contains an empty strings only

Arguments
  • array $array - The array to verify
Examples
  • array: [] (an empty array)
  • result: false
  • array: ["", -1]
  • result: false
  • array: ["", null, ""]
  • result: true

getNonEmptyValues(array $values)

Returns non-empty values, e.g. without "" (empty string), null or []

Arguments
  • array $values - The values to filter
Examples
  • values: [] (no values)
  • result: [] (an empty array)
  • values: [null, ""] (all empty values)
  • result: [] (an empty array)
  • 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: ", ".
Examples
  • values: [] (no values)
  • separator: default or any other string
  • result: "" (an empty string)
  • values: [null, ""] (all empty values)
  • separator: default or any other string
  • result: "" (an empty string)
  • values: ["test 1", "", 123, null, 0]
  • separator: ", " (default)
  • result: "test 1, 123, 0"
  • values: ["test 1", "", 123, null, 0]
  • separator: " | "
  • result: "test 1 | 123 | 0"

More

  1. Base test case (with common methods and data providers)
  2. Collection of elements
  3. Templates
  4. Exceptions
  5. Static methods
    1. Arrays
    2. Regex
    3. Uri
  6. Value Objects

‹ Back to Readme