src/Phossa/Shared/Message/MessageAbstract.php
protected static function buildMessage(
        /*# string */ $template,
        array $arguments
    )/*# : string */ {
        // use formatter
        if (self::hasFormatter()) {
            return self::getFormatter()
                    ->formatMessage($template, $arguments);

        // default is vsprintf()
        } else {
            // make sure arguments are all strings
            array_walk($arguments, function (&$value) {
                $value = is_scalar($value) ? (string) $value :
                    substr(print_r($value, true), 0, 50);
            });

            // make sure '%s' count in $template is same as size of $arguments
            $count = substr_count($template, '%s');
            $size  = sizeof($arguments);
            if ($count > $size) {
                $arguments = $arguments + array_fill($size, $count - $size, '');
            } else {
                $template .= str_repeat(' %s', $size - $count);
            }
            return vsprintf($template, $arguments);
        }
    }
protected static function buildMessage(
        /*# string */ $template,
        array $arguments
    )/*# : string */ {
        // use formatter
        if (self::hasFormatter()) {
            return self::getFormatter()
                    ->formatMessage($template, $arguments);

        // default is vsprintf()
        } else {
            // make sure arguments are all strings
            array_walk($arguments, function (&$value) {
                $value = is_scalar($value) ? (string) $value :
                    substr(print_r($value, true), 0, 50);
            });

            // make sure '%s' count in $template is same as size of $arguments
            $count = substr_count($template, '%s');
            $size  = sizeof($arguments);
            if ($count > $size) {
                $arguments = $arguments + array_fill($size, $count - $size, '');
            } else {
                $template .= str_repeat(' %s', $size - $count);
            }
            return vsprintf($template, $arguments);
        }
    }
protected static function buildMessage ( /*# string */ $ template , array $ arguments ) /*# : string */ { // use formatter if ( self :: hasFormatter ( ) ) { return self :: getFormatter ( ) -> formatMessage ( $ template , $ arguments ) ; // default is vsprintf() } else { // make sure arguments are all strings array_walk ( $ arguments , function ( & $ value ) { $ value = is_scalar ( $ value ) ? ( string ) $ value : substr ( print_r ( $ value , true ) , 0 , 50 ) ; } ) ; // make sure '%s' count in $template is same as size of $arguments $ count = substr_count ( $ template , '%s' ) ; $ size = sizeof ( $ arguments ) ; if ( $ count > $ size ) { $ arguments = $ arguments + array_fill ( $ size , $ count - $ size , '' ) ; } else { $ template .= str_repeat ( ' %s' , $ size - $ count ) ; } return vsprintf ( $ template , $ arguments ) ; } }
Build message from template and arguments.

- Make sure '%s' matches the arguments provided.
- Use message formatter if exists

@param  string $template message template
@param  array $arguments arguments for the template
@return string
@access protected
@static
Build message from template and arguments .