Ouzo\Utilities\Functions::extractExpression PHP Method

extractExpression() public static method

public static extractExpression ( $selector, $accessPrivate = false )
    public static function extractExpression($selector, $accessPrivate = false)
    {
        if (!is_string($selector)) {
            return $selector;
        } elseif (strpos($selector, '()') !== false || strpos($selector, '->') !== false) {
            return Functions::extractFieldRecursively($selector, $accessPrivate);
        } else {
            return Functions::extractField($selector, $accessPrivate);
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Returns comparator which compares objects by using values computed using given expressions.
  * Expressions should comply with format accepted by <code>Functions::extractExpression</code>.
  * Comparator returns an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
  *
  * @param mixed ...
  * @return callable
  */
 public static function compareBy()
 {
     $expressions = func_get_args();
     $comparators = Arrays::map($expressions, function ($expression) {
         return new EvaluatingComparator(Functions::extractExpression($expression));
     });
     return sizeof($comparators) == 1 ? $comparators[0] : new CompoundComparator($comparators);
 }
All Usage Examples Of Ouzo\Utilities\Functions::extractExpression