Loading src/Helpers/Build.php +12 −16 Original line number Diff line number Diff line Loading @@ -71,10 +71,9 @@ ) */ preg_match_all('/(cm|lineage|eelo|e)-([0-9\.]+)-\D?-?([\d_]+)?-([\w+]+)-([A-Za-z0-9]+)?-?([\w+]+)?/', $fileName, $tokens); $tokens = $this->removeTrailingDashes($tokens); $this->filePath = (substr($physicalPath, -1) === '/') ? $physicalPath . $fileName : $physicalPath . '/' . $fileName; $tokens = $this->formatTokens($tokens); $this->migrationFilePath = $physicalPath . '/migration_paths.json'; $this->channel = $this->_getChannel(str_replace(range(0, 9), '', $tokens[4]), $tokens[1], $tokens[2]); $this->filename = $fileName; Loading Loading @@ -392,22 +391,19 @@ /* Utility / Internal */ /** * Remove trailing dashes * @param type $token The string where to do the operation * @return string The string without trailing dashes * Remove trailing dashes and flatten match result into array of strings * @param array $tokens Array of arrays containing tokens as gotten from filename * @return array Array of strings containing tokens */ private function removeTrailingDashes($token) private function formatTokens($tokens) { foreach ($token as $key => $value) { if(isset($value[0]) && !empty($value[0])) { $token[$key] = trim($value[0], '-'); } else { $this->logger->warning("Token value null or not array for build located at: " . $this->filePath ); continue; } return array_map(function ($token) { if (isset($token[0]) && !empty($token[0])) { return trim($token[0], '-'); } else { return ''; } return $token; }, $tokens); } /** Loading Loading
src/Helpers/Build.php +12 −16 Original line number Diff line number Diff line Loading @@ -71,10 +71,9 @@ ) */ preg_match_all('/(cm|lineage|eelo|e)-([0-9\.]+)-\D?-?([\d_]+)?-([\w+]+)-([A-Za-z0-9]+)?-?([\w+]+)?/', $fileName, $tokens); $tokens = $this->removeTrailingDashes($tokens); $this->filePath = (substr($physicalPath, -1) === '/') ? $physicalPath . $fileName : $physicalPath . '/' . $fileName; $tokens = $this->formatTokens($tokens); $this->migrationFilePath = $physicalPath . '/migration_paths.json'; $this->channel = $this->_getChannel(str_replace(range(0, 9), '', $tokens[4]), $tokens[1], $tokens[2]); $this->filename = $fileName; Loading Loading @@ -392,22 +391,19 @@ /* Utility / Internal */ /** * Remove trailing dashes * @param type $token The string where to do the operation * @return string The string without trailing dashes * Remove trailing dashes and flatten match result into array of strings * @param array $tokens Array of arrays containing tokens as gotten from filename * @return array Array of strings containing tokens */ private function removeTrailingDashes($token) private function formatTokens($tokens) { foreach ($token as $key => $value) { if(isset($value[0]) && !empty($value[0])) { $token[$key] = trim($value[0], '-'); } else { $this->logger->warning("Token value null or not array for build located at: " . $this->filePath ); continue; } return array_map(function ($token) { if (isset($token[0]) && !empty($token[0])) { return trim($token[0], '-'); } else { return ''; } return $token; }, $tokens); } /** Loading