Skip to content

Commit ab4f536

Browse files
Merge pull request #364 from Laravel-Lang/16.x
Added the ability to check the name of the project
2 parents 214abf2 + e33931a commit ab4f536

File tree

8 files changed

+30
-16
lines changed

8 files changed

+30
-16
lines changed

src/Helpers/Config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class Config
2929

3030
public function __construct(
3131
readonly protected Arr $arr = new Arr()
32-
) {
33-
}
32+
) {}
3433

3534
public function getPlugins(): array
3635
{

src/Plugins/Plugin.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ abstract class Plugin
2626

2727
protected string $version = '*';
2828

29+
protected bool $with_project_name = false;
30+
2931
abstract public function files(): array;
3032

3133
public function vendor(): ?string
@@ -35,6 +37,10 @@ public function vendor(): ?string
3537

3638
public function has(): bool
3739
{
40+
if ($this->hasProjectName()) {
41+
return true;
42+
}
43+
3844
return $this->hasVendor() && $this->hasVersion();
3945
}
4046

@@ -55,4 +61,13 @@ private function hasVersion(): bool
5561

5662
return true;
5763
}
64+
65+
private function hasProjectName(): bool
66+
{
67+
if (! $this->with_project_name || ! $this->vendor()) {
68+
return false;
69+
}
70+
71+
return $this->vendor === (InstalledVersions::getRootPackage()['name'] ?? false);
72+
}
5873
}

src/Processors/Processor.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public function __construct(
5353
protected ArrHelper $arr = new ArrHelper(),
5454
protected Translation $translation = new Translation(
5555
)
56-
) {
57-
}
56+
) {}
5857

5958
public function prepare(): self
6059
{
@@ -142,15 +141,16 @@ protected function collectLocalizations(string $directory, array $files): void
142141
}
143142

144143
/**
145-
* @return array<\LaravelLang\Publisher\Plugins\Plugin>
144+
* @return array<Plugin>
146145
*/
147146
protected function plugins(): array
148147
{
149148
return collect($this->config->getPlugins())
150-
->map(fn (array $plugins) => collect($plugins)
151-
->map(static fn (string $plugin) => new $plugin())
152-
->filter(static fn (Plugin $plugin) => $plugin->has())
153-
->all()
149+
->map(
150+
fn (array $plugins) => collect($plugins)
151+
->map(static fn (string $plugin) => new $plugin())
152+
->filter(static fn (Plugin $plugin) => $plugin->has())
153+
->all()
154154
)
155155
->filter()
156156
->all();

src/Processors/Update.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@
1717

1818
namespace LaravelLang\Publisher\Processors;
1919

20-
class Update extends Processor
21-
{
22-
}
20+
class Update extends Processor { }

src/Resources/Translation.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class Translation implements Arrayable
2929

3030
public function __construct(
3131
readonly protected Arr $arr = new Arr()
32-
) {
33-
}
32+
) {}
3433

3534
public function getSource(string $filename): array
3635
{

src/Services/Converters/Text/BaseDecorator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ abstract class BaseDecorator implements TextDecorator
2424
{
2525
public function __construct(
2626
protected Config $config
27-
) {
28-
}
27+
) {}
2928
}

tests/Unit/Console/InlineOff/Update/Success/NestedAttributesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @see https://laravel-lang.com
1414
*/
1515

16+
declare(strict_types=1);
17+
1618
namespace Tests\Unit\Console\InlineOff\Update\Success;
1719

1820
use DragonCode\Support\Facades\Filesystem\Directory;

tests/Unit/Console/InlineOn/Update/Success/NestedAttributesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @see https://laravel-lang.com
1414
*/
1515

16+
declare(strict_types=1);
17+
1618
namespace Tests\Unit\Console\InlineOn\Update\Success;
1719

1820
use DragonCode\Support\Facades\Filesystem\Directory;

0 commit comments

Comments
 (0)