public function build($definition, $context = null, $name = null)
    {
        if ($definition instanceof ProviderInterface) {
            return $this->getProviderValue($definition, $context);
        } elseif ($definition instanceof FieldInterface) {
            return $definition->getResult($context);
        } elseif (is_array($definition)) {
            $result = [];
            foreach ($definition as $key => $value) {
                $result[$key] = $this->build($value, $context);
            }

            return new Record(
                $name === null ? 'record' : $name, 
                $result
            );
        } elseif (is_string($definition)) {
            if ($context !== null) {
                if (is_array($context)) {
                    if (array_key_exists($definition, $context)) {
                        return $context[$definition];
                    } else {
                        throw new RuntimeException('Referenced unknown key "' . $definition . '" in context');
                    }
                } elseif ($context instanceof \ArrayAccess) {
                    if ($context->offsetExists($definition)) {
                        return $context->offsetGet($definition);
                    } else {
                        throw new RuntimeException('Referenced unknown key "' . $definition . '" in context');
                    }
                } else {
                    throw new RuntimeException('Context must be either an array or instance of ArrayAccess');
                }
            } else {
                return $definition;
            }
        } else {
            return $definition;
        }
    }
public function build($definition, $context = null, $name = null)
    {
        if ($definition instanceof ProviderInterface) {
            return $this->getProviderValue($definition, $context);
        } elseif ($definition instanceof FieldInterface) {
            return $definition->getResult($context);
        } elseif (is_array($definition)) {
            $result = [];
            foreach ($definition as $key => $value) {
                $result[$key] = $this->build($value, $context);
            }

            return new Record(
                $name === null ? 'record' : $name, 
                $result
            );
        } elseif (is_string($definition)) {
            if ($context !== null) {
                if (is_array($context)) {
                    if (array_key_exists($definition, $context)) {
                        return $context[$definition];
                    } else {
                        throw new RuntimeException('Referenced unknown key "' . $definition . '" in context');
                    }
                } elseif ($context instanceof \ArrayAccess) {
                    if ($context->offsetExists($definition)) {
                        return $context->offsetGet($definition);
                    } else {
                        throw new RuntimeException('Referenced unknown key "' . $definition . '" in context');
                    }
                } else {
                    throw new RuntimeException('Context must be either an array or instance of ArrayAccess');
                }
            } else {
                return $definition;
            }
        } else {
            return $definition;
        }
    }
public function build ( $ definition , $ context = null , $ name = null ) { if ( $ definition instanceof ProviderInterface ) { return $ this -> getProviderValue ( $ definition , $ context ) ; } elseif ( $ definition instanceof FieldInterface ) { return $ definition -> getResult ( $ context ) ; } elseif ( is_array ( $ definition ) ) { $ result = [ ] ; foreach ( $ definition as $ key => $ value ) { $ result [ $ key ] = $ this -> build ( $ value , $ context ) ; } return new Record ( $ name === null ? 'record' : $ name , $ result ) ; } elseif ( is_string ( $ definition ) ) { if ( $ context !== null ) { if ( is_array ( $ context ) ) { if ( array_key_exists ( $ definition , $ context ) ) { return $ context [ $ definition ] ; } else { throw new RuntimeException ( 'Referenced unknown key "' . $ definition . '" in context' ) ; } } elseif ( $ context instanceof \ ArrayAccess ) { if ( $ context -> offsetExists ( $ definition ) ) { return $ context -> offsetGet ( $ definition ) ; } else { throw new RuntimeException ( 'Referenced unknown key "' . $ definition . '" in context' ) ; } } else { throw new RuntimeException ( 'Context must be either an array or instance of ArrayAccess' ) ; } } else { return $ definition ; } } else { return $ definition ; } }
Returns an array based on the resolved definition

@param mixed $definition
@param array $context
@param string $name
@return mixed
Returns an array based on the resolved definition