Ouzo\Utilities\Strings::trimToNull PHP Method

trimToNull() public static method

Example: $result = Strings::trimToNull(' '); Result: null
public static trimToNull ( string $string ) : string
$string string
return string
    public static function trimToNull($string)
    {
        $string = trim($string);
        if (mb_strlen($string) == 0) {
            return null;
        }
        return $string;
    }

Usage Example

Beispiel #1
0
 /**
  * @test
  */
 public function shouldTrimNull()
 {
     //given
     $string = null;
     //when
     $result = Strings::trimToNull($string);
     //then
     $this->assertNull($result);
 }