public static function from($repoDir)
 {
     // ask Git for the details
     $result = ExecInGitRepo::run($repoDir, ['git', 'branch', '--no-color']);
     // tidy up the returned text
     $branches = explode(PHP_EOL, $result->getOutput(), -1);
     $branches = ReplaceMatchingRegex::in($branches, '/^\\* /', '');
     $branches = TrimWhitespace::from($branches);
     // all done
     return $branches;
 }
 /**
  * @covers ::fromArray
  * @dataProvider provideTraversablesToFilter
  */
 public function testCanTrimTraversables($data, $expectedResult)
 {
     // ----------------------------------------------------------------
     // setup your test
     $obj = new TrimWhitespace();
     // ----------------------------------------------------------------
     // perform the change
     $actualResult1 = $obj($data);
     $actualResult2 = TrimWhitespace::from($data);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedResult, $actualResult1);
     $this->assertEquals($expectedResult, $actualResult2);
 }
 /**
  * extract a named field from the output of /usr/bin/sw_vers
  *
  * @param  array $lines
  *         the output of /usr/bin/sw_vers
  * @param  string $fieldName
  *         the field that we are looking for
  * @return string|null
  *         the value of the field (if found)
  */
 private static function extractField($lines, $fieldName)
 {
     $matches = FilterForMatchingString::against($lines, $fieldName);
     if (empty($matches)) {
         return null;
     }
     return TrimWhitespace::from(FilterColumns::from($matches[0], '1', ':'));
 }