code: private function stringToArray(string $string): array
      {
          $lines = preg_split('/\R/', $string);
          if (1 === count($lines) && '' === $lines[0]) {
              $lines = [];
          }
  
          return $lines;
      }
docs: Accepts console output as a string and returns an array of it split by newlines.