public function formatErrors($title = '')
    {
        $errorsStr = PHP_EOL;
        
        foreach ($this->errors as $k => $error) {
            $details = [];
            
            if (isset($error['details']) && is_array($error['details'])) {
                foreach ($error['details'] as $name => $value) {
                    $details[] = sprintf('%s:%s', $name, $value);
                }
            }
            
            $body = sprintf(
                'key: %smessage: %sdetails: %s',
                $error['key'] . PHP_EOL,
                $error['message'] . PHP_EOL,
                implode(' | ', $details) . PHP_EOL
            );
            $errorsStr .= $body . self::ERROR_OUTPUT_SEPARATOR . PHP_EOL;
        }
    
        $messageTemplate = $title . PHP_EOL
            . 'Response code: %s' . PHP_EOL
            . 'Response errors (%s): %s%s' . PHP_EOL;
    
        $output = vsprintf(
            $messageTemplate,
            [
                $this->getCode(),
                count($this->errors),
                PHP_EOL . self::ERROR_OUTPUT_SEPARATOR,
                $errorsStr,
            ]
        );
        
        return $output;
    }
public function formatErrors($title = '')
    {
        $errorsStr = PHP_EOL;
        
        foreach ($this->errors as $k => $error) {
            $details = [];
            
            if (isset($error['details']) && is_array($error['details'])) {
                foreach ($error['details'] as $name => $value) {
                    $details[] = sprintf('%s:%s', $name, $value);
                }
            }
            
            $body = sprintf(
                'key: %smessage: %sdetails: %s',
                $error['key'] . PHP_EOL,
                $error['message'] . PHP_EOL,
                implode(' | ', $details) . PHP_EOL
            );
            $errorsStr .= $body . self::ERROR_OUTPUT_SEPARATOR . PHP_EOL;
        }
    
        $messageTemplate = $title . PHP_EOL
            . 'Response code: %s' . PHP_EOL
            . 'Response errors (%s): %s%s' . PHP_EOL;
    
        $output = vsprintf(
            $messageTemplate,
            [
                $this->getCode(),
                count($this->errors),
                PHP_EOL . self::ERROR_OUTPUT_SEPARATOR,
                $errorsStr,
            ]
        );
        
        return $output;
    }
public function formatErrors ( $ title = '' ) { $ errorsStr = PHP_EOL ; foreach ( $ this -> errors as $ k => $ error ) { $ details = [ ] ; if ( isset ( $ error [ 'details' ] ) && is_array ( $ error [ 'details' ] ) ) { foreach ( $ error [ 'details' ] as $ name => $ value ) { $ details [ ] = sprintf ( '%s:%s' , $ name , $ value ) ; } } $ body = sprintf ( 'key: %smessage: %sdetails: %s' , $ error [ 'key' ] . PHP_EOL , $ error [ 'message' ] . PHP_EOL , implode ( ' | ' , $ details ) . PHP_EOL ) ; $ errorsStr .= $ body . self :: ERROR_OUTPUT_SEPARATOR . PHP_EOL ; } $ messageTemplate = $ title . PHP_EOL . 'Response code: %s' . PHP_EOL . 'Response errors (%s): %s%s' . PHP_EOL ; $ output = vsprintf ( $ messageTemplate , [ $ this -> getCode ( ) , count ( $ this -> errors ) , PHP_EOL . self :: ERROR_OUTPUT_SEPARATOR , $ errorsStr , ] ) ; return $ output ; }
Format errors.

@param string $title

@return string
Format errors .