View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Filter_StringPad
{zone-data}

{zone-data:proposer-list}
[~thomas]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 12 April 2009: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Filter_StringPad is a filter which allows to pad/extend a string to a given length.
{zone-data}

{zone-data:references}
* [Zend_Filter|http://framework.zend.com/manual/en/zend.filter.html]
{zone-data}

{zone-data:requirements}
* This component *will* pad a string to a given length
* This component *will* allow to pad/extend a string on both sides
* This component *will* allow to use any character to pad the string
{zone-data}

{zone-data:dependencies}
* Zend_Filter
{zone-data}

{zone-data:operation}
This component allows to pad/extend a string to a given length the same way as str_pad would be.
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] Proposal finished
* Milestone 2: Proposal accepted
* Milestone 3: Working implementation
* Milestone 4: Unit tests
* Milestone 5: Documentation
* Milestone 6: Moved to core
{zone-data}

{zone-data:class-list}
* Zend_Filter_StringPad
{zone-data}

{zone-data:use-cases}
||UC-01||
Pad a string to 15 chars
{code}
$filter = new Zend_Filter_StringPad(15);
$filter->filter('My string');
// returns 'My string '
{code}
||UC-02||
Pad a string to 15 chars, using another pad char
{code}
$filter = new Zend_Filter_StringPad(array('length' => 15, 'char' => '.'));
$filter->filter('My string');
// returns 'My string......'
{code}
||UC-03||
Pad a string to 15 chars, using another pad char and another direction
{code}
$filter = new Zend_Filter_StringPad(array('length' => 15, 'char' => '.', 'type' => Zend_Filter_StringPad::LEFT));
$filter->filter('My string');
// returns '......My string'
{code}

{zone-data}

{zone-data:skeletons}
{code}
class Zend_Filter_StringPad implements Zend_Filter_Interface {
/**
* @param string|integer|array $options (Optional) Options to set
*/
public function __construct($options = array())

/**
* @param integer $length Length to pad to
* @return Zend_Filter_StringPad
*/
public function setLength($length)

/**
* @return integer
*/
public function getLength()

/**
* @param string $character Character to use for padding
* @return Zend_Filter_StringPad
*/
public function setChar($character)

/**
* @return string
*/
public function getChar()

/**
* @param string $type Type to use for padding
* @return Zend_Filter_StringPad
*/
public function setType($type)

/**
* @return string
*/
public function getType()

/**
* @param string @value Value to filter
*/
public function filter($value)
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>