src/Mapper.php
public function map(array $record, $expression, $context = null, $key = null)
    {
        // Null or scalar values.
        if (null === $expression || is_scalar($expression)) {
            return $expression;
        }

        // Strategy.
        if ($expression instanceof Strategy) {
            return $this->mapStrategy($record, $expression, $context, $key);
        }

        // Mapping.
        if ($expression instanceof Mapping) {
            return $this->mapMapping($record, $expression, $context, $key);
        }

        // Mapping fragment.
        if (is_array($expression)) {
            return $this->mapFragment($record, $expression, $context, $key);
        }

        throw new InvalidExpressionException('Invalid strategy or mapping: "' . get_class($expression) . '".');
    }
public function map(array $record, $expression, $context = null, $key = null)
    {
        // Null or scalar values.
        if (null === $expression || is_scalar($expression)) {
            return $expression;
        }

        // Strategy.
        if ($expression instanceof Strategy) {
            return $this->mapStrategy($record, $expression, $context, $key);
        }

        // Mapping.
        if ($expression instanceof Mapping) {
            return $this->mapMapping($record, $expression, $context, $key);
        }

        // Mapping fragment.
        if (is_array($expression)) {
            return $this->mapFragment($record, $expression, $context, $key);
        }

        throw new InvalidExpressionException('Invalid strategy or mapping: "' . get_class($expression) . '".');
    }
public function map ( array $ record , $ expression , $ context = null , $ key = null ) { // Null or scalar values. if ( null === $ expression || is_scalar ( $ expression ) ) { return $ expression ; } // Strategy. if ( $ expression instanceof Strategy ) { return $ this -> mapStrategy ( $ record , $ expression , $ context , $ key ) ; } // Mapping. if ( $ expression instanceof Mapping ) { return $ this -> mapMapping ( $ record , $ expression , $ context , $ key ) ; } // Mapping fragment. if ( is_array ( $ expression ) ) { return $ this -> mapFragment ( $ record , $ expression , $ context , $ key ) ; } throw new InvalidExpressionException ( 'Invalid strategy or mapping: "' . get_class ( $ expression ) . '".' ) ; }
Maps the specified record according to the specified expression type. Optionally, used-defined contextual data
may be passed to the expression. The record key is for internal use only and represents the current array key.

May be called recursively if the expression embeds more expressions.

@param array $record Record.
@param Strategy|Mapping|array|mixed $expression Expression.
@param mixed $context Optional. Contextual data.
@param string|int|null $key Internal. Record key.

@return mixed

@throws InvalidExpressionException An invalid strategy or mapping object was specified.
Maps the specified record according to the specified expression type . Optionally used - defined contextual data may be passed to the expression . The record key is for internal use only and represents the current array key .