Skip to content

Commit e3b9913

Browse files
author
alexandresalome
committed
remove StringHelper from command parsers
1 parent d5f4dec commit e3b9913

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

src/Gitonomy/Git/Parser/CommitParser.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
namespace Gitonomy\Git\Parser;
1414

15-
use Gitonomy\Git\Util\StringHelper;
16-
1715
class CommitParser extends ParserBase
1816
{
1917
public $tree;
@@ -58,7 +56,7 @@ protected function consumeNameEmailDate()
5856
throw new \RuntimeException('Unable to parse name, email and date');
5957
}
6058

61-
$this->cursor += StringHelper::strlen($vars[1]);
59+
$this->cursor += strlen($vars[1]);
6260

6361
return array($vars[2], $vars[3], $vars[4]);
6462
}

src/Gitonomy/Git/Parser/DiffParser.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
use Gitonomy\Git\Diff\File;
1616
use Gitonomy\Git\Diff\FileChange;
17-
use Gitonomy\Git\Util\StringHelper;
1817
use Gitonomy\Git\Repository;
1918

2019
class DiffParser extends ParserBase
@@ -100,8 +99,8 @@ protected function doParse()
10099
}
101100
}
102101

103-
$oldName = $oldName === '/dev/null' ? null : StringHelper::substr($oldName, 2);
104-
$newName = $newName === '/dev/null' ? null : StringHelper::substr($newName, 2);
102+
$oldName = $oldName === '/dev/null' ? null : substr($oldName, 2);
103+
$newName = $newName === '/dev/null' ? null : substr($newName, 2);
105104
$oldIndex = preg_match('/^0+$/', $oldIndex) ? null : $oldIndex;
106105
$newIndex = preg_match('/^0+$/', $newIndex) ? null : $newIndex;
107106
$file = new File($this->repository, $oldName, $newName, $oldMode, $newMode, $oldIndex, $newIndex, $isBinary);

src/Gitonomy/Git/Parser/ParserBase.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function parse($content)
2626
{
2727
$this->cursor = 0;
2828
$this->content = $content;
29-
$this->length = StringHelper::strlen($this->content);
29+
$this->length = strlen($this->content);
3030

3131
$this->doParse();
3232
}
@@ -38,16 +38,16 @@ protected function isFinished()
3838

3939
protected function consumeAll()
4040
{
41-
$rest = StringHelper::substr($this->content, $this->cursor);
42-
$this->cursor += StringHelper::strlen($rest);
41+
$rest = substr($this->content, $this->cursor);
42+
$this->cursor += strlen($rest);
4343

4444
return $rest;
4545
}
4646

4747
protected function expects($expected)
4848
{
49-
$length = StringHelper::strlen($expected);
50-
$actual = StringHelper::substr($this->content, $this->cursor, $length);
49+
$length = strlen($expected);
50+
$actual = substr($this->content, $this->cursor, $length);
5151
if ($actual !== $expected) {
5252
return false;
5353
}
@@ -60,18 +60,18 @@ protected function expects($expected)
6060
protected function consumeShortHash()
6161
{
6262
if (!preg_match('/([A-Za-z0-9]{7,40})/A', $this->content, $vars, null, $this->cursor)) {
63-
throw new \RuntimeException('No short hash found: '.StringHelper::substr($this->content, $this->cursor, 7));
63+
throw new \RuntimeException('No short hash found: '.substr($this->content, $this->cursor, 7));
6464
}
6565

66-
$this->cursor += StringHelper::strlen($vars[1]);
66+
$this->cursor += strlen($vars[1]);
6767

6868
return $vars[1];
6969
}
7070

7171
protected function consumeHash()
7272
{
7373
if (!preg_match('/([A-Za-z0-9]{40})/A', $this->content, $vars, null, $this->cursor)) {
74-
throw new \RuntimeException('No hash found: '.StringHelper::substr($this->content, $this->cursor, 40));
74+
throw new \RuntimeException('No hash found: '.substr($this->content, $this->cursor, 40));
7575
}
7676

7777
$this->cursor += 40;
@@ -85,29 +85,29 @@ protected function consumeRegexp($regexp)
8585
throw new \RuntimeException('No match for regexp '.$regexp);
8686
}
8787

88-
$this->cursor += StringHelper::strlen($vars[0]);
88+
$this->cursor += strlen($vars[0]);
8989

9090
return $vars;
9191
}
9292

9393
protected function consumeTo($text)
9494
{
95-
$pos = StringHelper::strpos($this->content, $text, $this->cursor);
95+
$pos = strpos($this->content, $text, $this->cursor);
9696

9797
if (false === $pos) {
9898
throw new \RuntimeException(sprintf('Unable to find "%s"', $text));
9999
}
100100

101-
$result = StringHelper::substr($this->content, $this->cursor, $pos - $this->cursor);
101+
$result = substr($this->content, $this->cursor, $pos - $this->cursor);
102102
$this->cursor = $pos;
103103

104104
return $result;
105105
}
106106

107107
protected function consume($expected)
108108
{
109-
$length = StringHelper::strlen($expected);
110-
$actual = StringHelper::substr($this->content, $this->cursor, $length);
109+
$length = strlen($expected);
110+
$actual = substr($this->content, $this->cursor, $length);
111111
if ($actual !== $expected) {
112112
throw new \RuntimeException(sprintf('Expected "%s", but got "%s" (%s)', $expected, $actual, substr($this->content, $this->cursor, 10)));
113113
}

0 commit comments

Comments
 (0)