From 2455d05096b29b4b710d02f7a9f0dcac959b4c2a Mon Sep 17 00:00:00 2001 From: Giuseppe Mazzapica Date: Wed, 9 Mar 2022 13:36:32 +0100 Subject: [PATCH] Don't calculate basePath in LibraryProperties::buildNames --- src/Properties/LibraryProperties.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Properties/LibraryProperties.php b/src/Properties/LibraryProperties.php index 11e52df..77539dd 100644 --- a/src/Properties/LibraryProperties.php +++ b/src/Properties/LibraryProperties.php @@ -79,7 +79,8 @@ public static function new(string $composerJsonFile, ?string $baseUrl = null): L $properties[self::PROP_VERSION] = $version; } - [$basePath, $baseName, $name] = static::buildNames($composerJsonData, $composerJsonFile); + [$baseName, $name] = static::buildNames($composerJsonData); + $basePath = dirname($composerJsonFile); if (empty($properties[self::PROP_NAME])) { $properties[self::PROP_NAME] = $name; } @@ -94,15 +95,12 @@ public static function new(string $composerJsonFile, ?string $baseUrl = null): L /** * @param array $composerJsonData - * @param string $composerJsonFile * - * @return array{string, string, string} + * @return array{string, string} */ - private static function buildNames(array $composerJsonData, string $composerJsonFile): array + private static function buildNames(array $composerJsonData): array { $composerName = (string) ($composerJsonData['name'] ?? ''); - $basePath = dirname($composerJsonFile); - $packageNamePieces = explode('/', $composerName, 2); $basename = implode('-', $packageNamePieces); // "inpsyde/foo-bar-baz" => "Inpsyde Foo Bar Baz" @@ -111,7 +109,7 @@ private static function buildNames(array $composerJsonData, string $composerJson MB_CASE_TITLE ); - return [$basePath, $basename, $name]; + return [$basename, $name]; } /**