src/Primitive/String/String.php
public function trim($what = null)
    {
        switch ($this->retrieveValue($what))
        {
            case 'front':
                return new static(ltrim($this->string));
            case 'back':
                return new static(rtrim($this->string));
            case 'all':
                return $this->replaceRegex('[[:space:]]+', '');
            default:
                return new static(trim($this->string));
        }
    }
public function trim($what = null)
    {
        switch ($this->retrieveValue($what))
        {
            case 'front':
                return new static(ltrim($this->string));
            case 'back':
                return new static(rtrim($this->string));
            case 'all':
                return $this->replaceRegex('[[:space:]]+', '');
            default:
                return new static(trim($this->string));
        }
    }
Strip whitespace (or other characters) from a String
Can trim:
'front' from the beginning
'back' from the end
'all' all whitespace chars will be replace
null from the end and beginning

@param null|string|StringContract $what
@return static