Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dmason30 committed Oct 27, 2023
1 parent 30816bf commit 212e2c1
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions src/Readers/PhpLanguageFileReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,13 @@

namespace Fidum\LaravelTranslationFaker\Readers;

use Fidum\LaravelTranslationFaker\Contracts\Factories\LanguageKeyFactory as LanguageKeyFactoryContract;
use Fidum\LaravelTranslationFaker\Contracts\Factories\LanguageNamespaceKeyFactory as LanguageNamespaceKeyFactoryContract;
use Fidum\LaravelTranslationFaker\Contracts\Readers\LanguageFileReader as LanguageFileReaderContract;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Stringable;
use InvalidArgumentException;
use Symfony\Component\Finder\SplFileInfo;

class PhpLanguageFileReader implements LanguageFileReaderContract, LanguageKeyFactoryContract, LanguageNamespaceKeyFactoryContract
class PhpLanguageFileReader implements LanguageFileReaderContract
{
public function getLanguageKey(SplFileInfo $file, string $locale): string
{
return Str::of($file->getPath())
->finish(DIRECTORY_SEPARATOR)
->after(DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR)
->append($file->getFilenameWithoutExtension())
->toString();
}

public function getNamespaceHintedKey(SplFileInfo $file, string $locale, string $namespaceHint, string $key): string
{
return Str::of($namespaceHint)
->whenNotEmpty(fn (Stringable $str) => $str->append('::'))
->append($key)
->toString();
}

public function getTranslations(SplFileInfo $file): Collection
{
$translations = include $file->getPathname();
Expand Down

0 comments on commit 212e2c1

Please sign in to comment.