diff --git a/src/ValueFormatters/StringFormatter.php b/src/ValueFormatters/StringFormatter.php index 11e4324..8e8b466 100644 --- a/src/ValueFormatters/StringFormatter.php +++ b/src/ValueFormatters/StringFormatter.php @@ -30,7 +30,7 @@ public function format( $dataValue ) { throw new InvalidArgumentException( 'DataValue is not a StringValue.' ); } - return $dataValue->getValue(); + return trim( $dataValue->getValue() ); } } diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index 3095665..87c077c 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -26,17 +26,20 @@ class StringFormatterTest extends ValueFormatterTestBase { */ public function validProvider() { $strings = array( - 'ice cream', - 'cake', - '', - ' a ', - ' ', + 'ice cream' => 'ice cream', + 'cake' => 'cake', + '' => '', + ' a ' => 'a', + ' a' => 'a', + 'a ' => 'a', + ' ' => '', + ' ' => '', ); $argLists = array(); - foreach ( $strings as $string ) { - $argLists[] = array( new StringValue( $string ), $string ); + foreach ( $strings as $value => $expected ) { + $argLists[] = array( new StringValue( $value ), $expected ); } return $argLists;