Flow\JSONPath\AccessHelper::getValue PHP Méthode

getValue() public static méthode

public static getValue ( $collection, $key, $magicIsAllowed = false )
    public static function getValue($collection, $key, $magicIsAllowed = false)
    {
        if ($magicIsAllowed && is_object($collection) && method_exists($collection, '__get')) {
            return $collection->__get($key);
        }
        if (is_object($collection) && !$collection instanceof \ArrayAccess) {
            return $collection->{$key};
        } else {
            return $collection[$key];
        }
    }

Usage Example

 /**
  * @param $collection
  * @return array
  */
 public function filter($collection)
 {
     $return = [];
     foreach ($this->token->value as $index) {
         if (AccessHelper::keyExists($collection, $index, $this->magicIsAllowed)) {
             $return[] = AccessHelper::getValue($collection, $index, $this->magicIsAllowed);
         }
     }
     return $return;
 }
All Usage Examples Of Flow\JSONPath\AccessHelper::getValue