Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Strip whitespace (or other characters) from the beginning and end of a string
<?php trim(string $string, string $characters = " \n\r\t\v\x00"): string
<?php     protected function getCurrentBranch(string $directory): string

    {

        $branch = "'".trim((string)shell_exec("cd ${directory}; git branch | grep \\* | cut -d ' ' -f2"))."'";



        if ($branch === "''") {

            $branch = 'current branch';