View Source

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

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

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

{zone-data:revision}
1.0 - 04 Oktober 2009
{zone-data}

{zone-data:overview}
Zend_Filter_StripSpaces will strip all spaces out of a string. You can specify if you want to strip out all spaces or just the unnecessary ones, means multiple spaces behind one another.
{zone-data}

{zone-data:references}
* [Issue ZF-2531|http://framework.zend.com/issues/browse/ZF-2531]
{zone-data}

{zone-data:requirements}
* This component *will* correctly strip out all repeated spaces, as they are insignificat in some context (e.g. html)
* This component *will* correctly strip out all spaces, when specified
* This component *will* also handle Unicode White Spaces
* This component *will not* remove any other character
{zone-data}

{zone-data:dependencies}
* Zend_Filter_Interface
* Zend_Filter_Exception
{zone-data}

{zone-data:operation}
Based on the specified options, this filter will strip all, more than one and/or also unicode white spaces.
{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_StripSpaces
{zone-data}

{zone-data:use-cases}
||UC-01||
Default, stripping multiple whitespaces (textual, unicode and html)
{code}
$text = 'Hello World';
$filter = new Zend_Filter_StripSpaces();
echo $filter->filter($text);
// returns 'Hello World'
{code}

||UC-02||
Stripping only multiple textual whitespaces
{code}
$text = 'Hello World';
$filter = new Zend_Filter_StripSpaces(Zend_Filter_StripSpaces::SPACE);
echo $filter->filter($text);
// returns 'Hello World'
{code}

||UC-03||
Stripping all whitespaces
{code}
$text = 'Hello&nbsp;&nbsp;World';
$filter = new Zend_Filter_StripSpaces(array('count' => 0);
echo $filter->filter($text);
// returns 'HelloWorld'
{code}

||UC-04||
Stripping multiple types of whitespaces
{code}
$text = 'Hello&nbsp;&nbsp;&nbsp; World';
$filter = new Zend_Filter_StripSpaces(array('count' => 0);
echo $filter->filter($text);
// returns 'HelloWorld'
{code}

||UC-05||
Stripping more than 3 whitespaces
{code}
$text = 'Hello World';
$filter = new Zend_Filter_StripSpaces(array('count' => 3);
echo $filter->filter($text);
// returns 'Hello World'
{code}
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Filter_StripSpaces
{
const SPACE = 1;
const UNICODE_SPACE = 2;
const HTML_SPACE = 4;
const ALL = 8;

public function __construct($options = null) { }

/**
* Sets the space type to strip, defaults to ALL, see constants
*/
public function setType($type = self::ALL) { }

/**
* Returns the set space type
*/
public function getType() { }

/**
* Sets the space count to strip, defaults to 1
*/
public function setCount($count = 1) { }

/**
* Returns the set space count
*/
public function getCount() { }

public function filter($value) { }

}
{code}
{zone-data}

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