* @license PHP License * @package WB * @subpackage db */ WBClass::load('WBDatasource_Decorator'); /** * Simple datasource decorator: Sprintf * * @version 0.1.1 * @package WB * @subpackage db */ class WBDatasource_Decorator_Sprintf extends WBDatasource_Decorator { /** * decorator's parameter list * * Parameters: * - format: sprinf format string * - columns: list of columns to format * * @var array */ protected $parameter = array( 'format' => '%s', 'column' => array(), ); /** * setup column buffers */ public function onStart(&$item) { } /** * actually decorate list item * * @param array $item * @return void */ public function decorate(&$item) { foreach ($this->parameter['column'] as $c) { $item[$c] = sprintf($this->parameter['format'], $item[$c]); } } }