src/Mordilion/Configurable/Configuration/Writer/Yaml.php
private function encode($configuration): string
    {
        if ($configuration instanceof ConfigurationInterface) {
            $configuration = $configuration->toArray();
        }

        if (!is_array($configuration)) {
            throw new \InvalidArgumentException('The provided configuration is not an array or an instance of ConfigurationInterface.');
        }

        $encoder = $this->getEncoder();

        if ($encoder === null) {
            throw new \RuntimeException('You didn\'t specify a encoder.');
        }

        $result = call_user_func_array($encoder, array_merge(array($configuration), $this->getEncoderParameters()));

        if ($result !== false) {
            return $result;
        }

        throw new \RuntimeException('The provided YAML is not valid.');
    }
private function encode($configuration): string
    {
        if ($configuration instanceof ConfigurationInterface) {
            $configuration = $configuration->toArray();
        }

        if (!is_array($configuration)) {
            throw new \InvalidArgumentException('The provided configuration is not an array or an instance of ConfigurationInterface.');
        }

        $encoder = $this->getEncoder();

        if ($encoder === null) {
            throw new \RuntimeException('You didn\'t specify a encoder.');
        }

        $result = call_user_func_array($encoder, array_merge(array($configuration), $this->getEncoderParameters()));

        if ($result !== false) {
            return $result;
        }

        throw new \RuntimeException('The provided YAML is not valid.');
    }
private function encode ( $ configuration ) : string { if ( $ configuration instanceof ConfigurationInterface ) { $ configuration = $ configuration -> toArray ( ) ; } if ( ! is_array ( $ configuration ) ) { throw new \ InvalidArgumentException ( 'The provided configuration is not an array or an instance of ConfigurationInterface.' ) ; } $ encoder = $ this -> getEncoder ( ) ; if ( $ encoder === null ) { throw new \ RuntimeException ( 'You didn\'t specify a encoder.' ) ; } $ result = call_user_func_array ( $ encoder , array_merge ( array ( $ configuration ) , $ this -> getEncoderParameters ( ) ) ) ; if ( $ result !== false ) { return $ result ; } throw new \ RuntimeException ( 'The provided YAML is not valid.' ) ; }
Encodes the provided $configuration into a YAML string.

@param array|ConfigurationInterface $configuration

@throws \InvalidArgumentException if the provided configuration is not an array or an instance of ConfigurationInterface
@throws \RuntimeException if a encoder is not specified
@throws \RuntimeException if the encoder returned not a valid YAML

@return string
Encodes the provided $configuration into a YAML string .