public function parse()
    {
        // Split up the TAP string into an array of lines, then
        // trim all of the lines so there's no leading or trailing whitespace.
        $this->lines = array_map('rtrim', explode("\n", $this->tapString));
        $this->lineNumber = 0;

        $this->testCount = false;
        $this->results = array();

        $header = $this->findTapLog();

        $line = $this->nextLine();
        if ($line === $header) {
            throw new Exception("Duplicated TAP log, please check the configuration.");
        }

        while ($line !== false && ($this->testCount === false || count($this->results) < $this->testCount)) {
            $this->parseLine($line);
            $line = $this->nextLine();
        }

        if (false !== $this->testCount && count($this->results) !== $this->testCount) {
            throw new Exception(Lang::get('tap_error'));
        }

        return $this->results;
    }