Skip to content

Commit

Permalink
Migrate to laravel-lang/locales. Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Oct 30, 2023
1 parent d46226e commit 7952086
Show file tree
Hide file tree
Showing 52 changed files with 943 additions and 1,233 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"illuminate/collections": "^10.0",
"illuminate/console": "^10.0",
"illuminate/support": "^10.0",
"laravel-lang/locales": "^1.3.1",
"laravel-lang/locales": "^1.5.0",
"league/commonmark": "^2.4.1"
},
"require-dev": {
Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
cacheResult="false"
colors="true"
>
Expand All @@ -37,9 +36,5 @@
<include>
<directory>./src</directory>
</include>
<exclude>
<file>src/ServiceProvider.php</file>
<directory>src/Facades</directory>
</exclude>
</source>
</phpunit>
4 changes: 1 addition & 3 deletions src/Console/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class Remove extends Base
protected function locales(): array
{
if ($this->confirmAll()) {
return collect(Locales::raw()->installed())
->filter(static fn (string $locale) => ! Locales::isProtected($locale) || $this->option('force'))
->all();
return Locales::raw()->installed(false);
}

$locales = $this->getLocalesArgument();
Expand Down
12 changes: 0 additions & 12 deletions src/Helpers/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,9 @@
namespace LaravelLang\Publisher\Helpers;

use DragonCode\Support\Facades\Helpers\Arr as DragonArr;
use DragonCode\Support\Helpers\Ables\Arrayable;
use Illuminate\Support\Arr as IlluminateArr;

class Arr
{
public function of(mixed $array): Arrayable
{
return DragonArr::of($array);
}

public function get(array $array, int|string $key, mixed $default = null): mixed
{
return IlluminateArr::get($array, $key, $default);
}

public function merge(array $source, array $target, bool $filter_keys = false): array
{
foreach ($this->filter($source, $target, $filter_keys) as $key => $value) {
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function setPackage(string $base_path, string $plugin_class, string $pack

public function langPath(Locale|string|null ...$paths): string
{
$path = $this->arr->of($paths)
$path = collect($paths)
->filter()
->map(fn (Locale|string $value) => $this->toAlias($value))
->implode('/');
Expand Down
23 changes: 11 additions & 12 deletions src/Processors/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public function store(): void
$this->task($filename, function () use ($filename, $values, $locale) {
$path = $this->config->langPath($filename);

$values =
$this->reset || ! File::exists($path)
? $values
: $this->arr->merge(
$values
= $this->reset || ! File::exists($path)
? $values
: $this->arr->merge(
$this->filesystem->load($path),
$values
);
Expand Down Expand Up @@ -138,14 +138,13 @@ protected function collectLocalizations(string $directory): void
*/
protected function plugins(): array
{
return $this->arr->of($this->config->getPlugins())
->map(function (array $plugins): array {
return $this->arr->of($plugins)
->map(static fn (string $plugin) => new $plugin())
->filter(static fn (Plugin $plugin) => $plugin->has())
->toArray();
})
return collect($this->config->getPlugins())
->map(fn (array $plugins) => collect($plugins)
->map(static fn (string $plugin) => new $plugin())
->filter(static fn (Plugin $plugin) => $plugin->has())
->all()
)
->filter()
->toArray();
->all();
}
}
6 changes: 4 additions & 2 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ protected function bootCommands(): void

protected function bootPublishes(): void
{
$this->publishes([__DIR__ . '/../config/public.php' => $this->app->configPath(Config::PublicKey() . '.php'),],
'config');
$this->publishes(
[__DIR__ . '/../config/public.php' => $this->app->configPath(Config::PublicKey() . '.php')],
['config', Config::PublicKey()]
);
}

protected function registerConfig(): void
Expand Down
Loading

0 comments on commit 7952086

Please sign in to comment.