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