Skip to content

Commit d83dcce

Browse files
Copilotdermatz
andcommitted
Refactor: Extract theme name parsing logic to reduce duplication
Co-authored-by: dermatz <6103201+dermatz@users.noreply.github.com>
1 parent ca26e55 commit d83dcce

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

src/Console/Command/Static/CleanCommand.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Magento\Framework\App\Filesystem\DirectoryList;
88
use Magento\Framework\Console\Cli;
99
use Magento\Framework\Filesystem;
10-
use Magento\Framework\Filesystem\Directory\WriteInterface;
1110
use OpenForgeProject\MageForge\Console\Command\AbstractCommand;
1211
use OpenForgeProject\MageForge\Model\ThemeList;
1312
use OpenForgeProject\MageForge\Model\ThemePath;
@@ -118,8 +117,8 @@ private function cleanViewPreprocessed(string $themeName): int
118117
$varDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
119118

120119
// Extract vendor and theme parts
121-
$themeParts = explode('/', $themeName);
122-
if (count($themeParts) !== 2) {
120+
$themeParts = $this->parseThemeName($themeName);
121+
if ($themeParts === null) {
123122
return 0;
124123
}
125124

@@ -164,8 +163,8 @@ private function cleanPubStatic(string $themeName): int
164163
$staticDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
165164

166165
// Extract vendor and theme parts
167-
$themeParts = explode('/', $themeName);
168-
if (count($themeParts) !== 2) {
166+
$themeParts = $this->parseThemeName($themeName);
167+
if ($themeParts === null) {
169168
return 0;
170169
}
171170

@@ -191,4 +190,20 @@ private function cleanPubStatic(string $themeName): int
191190

192191
return $cleaned;
193192
}
193+
194+
/**
195+
* Parse theme name into vendor and theme parts
196+
*
197+
* @param string $themeName
198+
* @return array|null Array with [vendor, theme] or null if invalid format
199+
*/
200+
private function parseThemeName(string $themeName): ?array
201+
{
202+
$themeParts = explode('/', $themeName);
203+
if (count($themeParts) !== 2) {
204+
return null;
205+
}
206+
207+
return $themeParts;
208+
}
194209
}

0 commit comments

Comments
 (0)