33namespace Fidum \LaravelTranslationLinter \Linters ;
44
55use Fidum \LaravelTranslationLinter \Contracts \Collections \ResultObjectCollection ;
6+ use Fidum \LaravelTranslationLinter \Contracts \Factories \LanguageKeyFactory ;
67use Fidum \LaravelTranslationLinter \Contracts \Finders \LanguageFileFinder ;
8+ use Fidum \LaravelTranslationLinter \Contracts \Finders \LanguageNamespaceFinder ;
79use Fidum \LaravelTranslationLinter \Contracts \Linters \UnusedTranslationLinter as UnusedTranslationLinterContract ;
10+ use Fidum \LaravelTranslationLinter \Contracts \Readers \ApplicationFileReader ;
11+ use Fidum \LaravelTranslationLinter \Contracts \Readers \LanguageFileReader ;
812use Fidum \LaravelTranslationLinter \Data \ResultObject ;
9- use Fidum \LaravelTranslationLinter \Finders \LanguageNamespaceFinder ;
10- use Fidum \LaravelTranslationLinter \Readers \ApplicationFileReader ;
11- use Fidum \LaravelTranslationLinter \Readers \LanguageFileReader ;
1213use Illuminate \Support \Arr ;
1314use Illuminate \Support \Str ;
1415use Illuminate \Support \Stringable ;
@@ -20,6 +21,7 @@ public function __construct(
2021 protected ApplicationFileReader $ used ,
2122 protected LanguageFileFinder $ files ,
2223 protected LanguageFileReader $ translations ,
24+ protected LanguageKeyFactory $ factory ,
2325 protected LanguageNamespaceFinder $ namespaces ,
2426 protected ResultObjectCollection $ results ,
2527 protected array $ locales ,
@@ -37,10 +39,10 @@ public function execute(): ResultObjectCollection
3739
3840 /** @var SplFileInfo $file */
3941 foreach ($ files as $ file ) {
40- $ translations = $ this ->translations ->execute ($ file );
42+ $ translations = $ this ->translations ->getTranslations ($ file );
4143
4244 foreach ($ translations as $ field => $ children ) {
43- $ group = $ this ->getLanguageKey ($ file , $ locale , $ field );
45+ $ group = $ this ->factory -> getLanguageKey ($ file , $ locale , $ field );
4446
4547 foreach (Arr::dot (Arr::wrap ($ children )) as $ key => $ value ) {
4648 $ groupedKey = Str::of ($ group )
@@ -70,19 +72,4 @@ public function execute(): ResultObjectCollection
7072
7173 return $ this ->results ;
7274 }
73-
74- protected function getLanguageKey (SplFileInfo $ file , string $ language , string $ key ): string
75- {
76- if ($ file ->getExtension () === 'json ' ) {
77- return $ key ;
78- }
79-
80- return Str::of ($ file ->getPath ())
81- ->finish (DIRECTORY_SEPARATOR )
82- ->after (DIRECTORY_SEPARATOR .$ language .DIRECTORY_SEPARATOR )
83- ->append ($ file ->getFilenameWithoutExtension ())
84- ->append ('. ' )
85- ->append ($ key )
86- ->toString ();
87- }
8875}
0 commit comments