Skip to content

Commit 4156b80

Browse files
committed
FilepathNamespaceExtractor - use StringHelper::startsWith
1 parent 861c00d commit 4156b80

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

SlevomatCodingStandard/Sniffs/Files/FilepathNamespaceExtractor.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace SlevomatCodingStandard\Sniffs\Files;
44

5+
use SlevomatCodingStandard\Helpers\StringHelper;
6+
57
class FilepathNamespaceExtractor
68
{
79

@@ -35,7 +37,7 @@ public function getTypeNameFromProjectPath($path)
3537
while (count($pathParts) > 0) {
3638
array_shift($pathParts);
3739
foreach ($this->rootNamespaces as $directory => $namespace) {
38-
if (self::startsWith(implode('/', $pathParts) . '/', $directory . '/')) {
40+
if (StringHelper::startsWith(implode('/', $pathParts) . '/', $directory . '/')) {
3941
for ($i = 0; $i < count(explode('/', $directory)); $i++) {
4042
array_shift($pathParts);
4143
}
@@ -71,16 +73,4 @@ public function getTypeNameFromProjectPath($path)
7173
return pathinfo($typeName, PATHINFO_FILENAME);
7274
}
7375

74-
/**
75-
* @param string $haystack
76-
* @param string $needle
77-
* @return boolean
78-
*/
79-
private static function startsWith($haystack, $needle)
80-
{
81-
// todo do helperu
82-
83-
return strncmp($haystack, $needle, strlen($needle)) === 0;
84-
}
85-
8676
}

0 commit comments

Comments
 (0)