Skip to content

Commit 47d3dc0

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents f5fc11d + 92e26c5 commit 47d3dc0

22 files changed

+134
-152
lines changed

src/Commands/MakeExportCommand.php

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace BinaryCats\Exportify\Commands;
44

55
use Illuminate\Console\GeneratorCommand;
6-
use Illuminate\Support\Str;
76
use Illuminate\Support\Facades\File;
7+
use Illuminate\Support\Str;
88
use Symfony\Component\Console\Input\InputOption;
99

1010
class MakeExportCommand extends GeneratorCommand
@@ -39,7 +39,7 @@ public function handle(): int
3939
$dryRun = $this->option('dry-run');
4040

4141
$files = [
42-
$this->getPath($this->qualifyClass($name))
42+
$this->getPath($this->qualifyClass($name)),
4343
];
4444

4545
// Create factory if requested
@@ -84,44 +84,44 @@ public function handle(): int
8484
*/
8585
protected function getStub(): string
8686
{
87-
return __DIR__ . '/../../stubs/exportable.stub';
87+
return __DIR__.'/../../stubs/exportable.stub';
8888
}
8989

9090
/**
9191
* Get the default namespace for the class.
9292
*/
9393
protected function getDefaultNamespace($rootNamespace): string
9494
{
95-
return $rootNamespace . '\\Exports';
95+
return $rootNamespace.'\\Exports';
9696
}
9797

9898
/**
9999
* Create the factory class
100100
*/
101101
protected function createFactory(string $name, bool $dryRun): string
102102
{
103-
$className = Str::studly($name) . 'ExportFactory';
104-
$namespace = $this->rootNamespace() . 'ExportFactories';
105-
$path = $this->getPath($namespace . '\\' . $className);
103+
$className = Str::studly($name).'ExportFactory';
104+
$namespace = $this->rootNamespace().'ExportFactories';
105+
$path = $this->getPath($namespace.'\\'.$className);
106106

107-
if (!$dryRun) {
107+
if (! $dryRun) {
108108
$this->ensureDirectoryExists(dirname($path));
109-
$stub = File::get(__DIR__ . '/../../stubs/exportable_factory.stub');
110-
$exportClass = Str::studly($name) . 'Export';
109+
$stub = File::get(__DIR__.'/../../stubs/exportable_factory.stub');
110+
$exportClass = Str::studly($name).'Export';
111111
$content = str_replace(
112112
[
113113
'{{ namespace }}',
114114
'{{ class }}',
115115
'{{ exportableNamespace }}',
116116
'{{ exportableClass }}',
117-
'{{ livewireClass }}'
117+
'{{ livewireClass }}',
118118
],
119119
[
120120
$namespace,
121121
$className,
122-
$this->rootNamespace() . 'Exports',
122+
$this->rootNamespace().'Exports',
123123
$exportClass,
124-
'Export' . Str::studly($name)
124+
'Export'.Str::studly($name),
125125
],
126126
$stub
127127
);
@@ -136,26 +136,26 @@ protected function createFactory(string $name, bool $dryRun): string
136136
*/
137137
protected function createPolicy(string $name, bool $dryRun): string
138138
{
139-
$className = Str::studly($name) . 'ExportPolicy';
140-
$namespace = $this->rootNamespace() . 'Policies';
141-
$path = $this->getPath($namespace . '\\' . $className);
139+
$className = Str::studly($name).'ExportPolicy';
140+
$namespace = $this->rootNamespace().'Policies';
141+
$path = $this->getPath($namespace.'\\'.$className);
142142

143-
if (!$dryRun) {
143+
if (! $dryRun) {
144144
$this->ensureDirectoryExists(dirname($path));
145-
$stub = File::get(__DIR__ . '/../../stubs/exportable_policy.stub');
146-
$exportClass = Str::studly($name) . 'Export';
145+
$stub = File::get(__DIR__.'/../../stubs/exportable_policy.stub');
146+
$exportClass = Str::studly($name).'Export';
147147
$content = str_replace(
148148
[
149149
'{{ namespace }}',
150150
'{{ class }}',
151151
'{{ exportableNamespace }}',
152-
'{{ exportableClass }}'
152+
'{{ exportableClass }}',
153153
],
154154
[
155155
$namespace,
156156
$className,
157-
$this->rootNamespace() . 'Exports',
158-
$exportClass
157+
$this->rootNamespace().'Exports',
158+
$exportClass,
159159
],
160160
$stub
161161
);
@@ -170,36 +170,36 @@ protected function createPolicy(string $name, bool $dryRun): string
170170
*/
171171
protected function createLivewire(string $name, bool $dryRun): string
172172
{
173-
$className = 'Export' . Str::studly($name);
174-
$namespace = $this->rootNamespace() . 'Livewire';
175-
$path = $this->getPath($namespace . '\\' . $className);
176-
$viewName = 'export-' . Str::kebab($name);
173+
$className = 'Export'.Str::studly($name);
174+
$namespace = $this->rootNamespace().'Livewire';
175+
$path = $this->getPath($namespace.'\\'.$className);
176+
$viewName = 'export-'.Str::kebab($name);
177177

178-
if (!$dryRun) {
178+
if (! $dryRun) {
179179
$this->ensureDirectoryExists(dirname($path));
180-
$stub = File::get(__DIR__ . '/../../stubs/exportable_livewire.stub');
181-
$factoryClass = Str::studly($name) . 'ExportFactory';
180+
$stub = File::get(__DIR__.'/../../stubs/exportable_livewire.stub');
181+
$factoryClass = Str::studly($name).'ExportFactory';
182182
$content = str_replace(
183183
[
184184
'{{ namespace }}',
185185
'{{ class }}',
186186
'{{ factoryNamespace }}',
187187
'{{ factoryClass }}',
188-
'{{ view }}'
188+
'{{ view }}',
189189
],
190190
[
191191
$namespace,
192192
$className,
193-
$this->rootNamespace() . 'ExportFactories',
193+
$this->rootNamespace().'ExportFactories',
194194
$factoryClass,
195-
$viewName
195+
$viewName,
196196
],
197197
$stub
198198
);
199199
File::put($path, $content);
200200

201201
// Create the view file
202-
$viewPath = resource_path('views/livewire/' . $viewName . '.blade.php');
202+
$viewPath = resource_path('views/livewire/'.$viewName.'.blade.php');
203203
$this->ensureDirectoryExists(dirname($viewPath));
204204
File::put($viewPath, '<div><!-- TODO: Implement export view --></div>');
205205
}
@@ -223,13 +223,13 @@ protected function createTests(string $name, array $files, bool $dryRun): array
223223
default => 'exportable_livewire'
224224
};
225225

226-
$testClassName = $className . 'Test';
227-
$testPath = base_path('tests/Feature/' . str_replace('app/', '', dirname($file)) . '/' . $testClassName . '.php');
228-
$testNamespace = 'Tests\\Feature\\' . str_replace('/', '\\', str_replace('app/', '', dirname($file)));
226+
$testClassName = $className.'Test';
227+
$testPath = base_path('tests/Feature/'.str_replace('app/', '', dirname($file)).'/'.$testClassName.'.php');
228+
$testNamespace = 'Tests\\Feature\\'.str_replace('/', '\\', str_replace('app/', '', dirname($file)));
229229

230-
if (!$dryRun) {
230+
if (! $dryRun) {
231231
$this->ensureDirectoryExists(dirname($testPath));
232-
$stub = File::get(__DIR__ . '/../../stubs/' . $type . '_test.stub');
232+
$stub = File::get(__DIR__.'/../../stubs/'.$type.'_test.stub');
233233

234234
$replacements = [
235235
'{{ namespace }}' => $testNamespace,
@@ -239,25 +239,25 @@ protected function createTests(string $name, array $files, bool $dryRun): array
239239
// Add specific replacements based on type
240240
switch ($type) {
241241
case 'exportable':
242-
$replacements['{{ exportableNamespace }}'] = $this->rootNamespace() . 'Exports';
243-
$replacements['{{ exportableClass }}'] = Str::studly($name) . 'Export';
242+
$replacements['{{ exportableNamespace }}'] = $this->rootNamespace().'Exports';
243+
$replacements['{{ exportableClass }}'] = Str::studly($name).'Export';
244244
break;
245245
case 'exportable_factory':
246-
$replacements['{{ factoryNamespace }}'] = $this->rootNamespace() . 'ExportFactories';
247-
$replacements['{{ factoryClass }}'] = Str::studly($name) . 'ExportFactory';
246+
$replacements['{{ factoryNamespace }}'] = $this->rootNamespace().'ExportFactories';
247+
$replacements['{{ factoryClass }}'] = Str::studly($name).'ExportFactory';
248248
break;
249249
case 'exportable_policy':
250-
$replacements['{{ policyNamespace }}'] = $this->rootNamespace() . 'Policies';
251-
$replacements['{{ policyClass }}'] = Str::studly($name) . 'ExportPolicy';
252-
$replacements['{{ exportableNamespace }}'] = $this->rootNamespace() . 'Exports';
253-
$replacements['{{ exportableClass }}'] = Str::studly($name) . 'Export';
250+
$replacements['{{ policyNamespace }}'] = $this->rootNamespace().'Policies';
251+
$replacements['{{ policyClass }}'] = Str::studly($name).'ExportPolicy';
252+
$replacements['{{ exportableNamespace }}'] = $this->rootNamespace().'Exports';
253+
$replacements['{{ exportableClass }}'] = Str::studly($name).'Export';
254254
break;
255255
case 'exportable_livewire':
256-
$replacements['{{ livewireNamespace }}'] = $this->rootNamespace() . 'Livewire';
257-
$replacements['{{ livewireClass }}'] = 'Export' . Str::studly($name);
258-
$replacements['{{ factoryNamespace }}'] = $this->rootNamespace() . 'ExportFactories';
259-
$replacements['{{ factoryClass }}'] = Str::studly($name) . 'ExportFactory';
260-
$replacements['{{ view }}'] = 'export-' . Str::kebab($name);
256+
$replacements['{{ livewireNamespace }}'] = $this->rootNamespace().'Livewire';
257+
$replacements['{{ livewireClass }}'] = 'Export'.Str::studly($name);
258+
$replacements['{{ factoryNamespace }}'] = $this->rootNamespace().'ExportFactories';
259+
$replacements['{{ factoryClass }}'] = Str::studly($name).'ExportFactory';
260+
$replacements['{{ view }}'] = 'export-'.Str::kebab($name);
261261
break;
262262
}
263263

@@ -294,8 +294,8 @@ protected function getOptions(): array
294294
*/
295295
protected function ensureDirectoryExists(string $path): void
296296
{
297-
if (!File::isDirectory($path)) {
297+
if (! File::isDirectory($path)) {
298298
File::makeDirectory($path, 0755, true);
299299
}
300300
}
301-
}
301+
}

src/Components/Exportable.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ class Exportable extends Component
1010
{
1111
public function __construct(
1212
public readonly ExportFactory $exportFactory
13-
) {
14-
}
13+
) {}
1514

1615
/**
1716
* Get the contents that represent the exportable component.
@@ -20,4 +19,4 @@ public function render(): View
2019
{
2120
return view('exportify::components.exportable');
2221
}
23-
}
22+
}

src/Components/ListExportables.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ class ListExportables extends Component
1414
*/
1515
public function __construct(
1616
public readonly string|array $tagged = []
17-
) {
18-
}
17+
) {}
1918

2019
/**
2120
* Get the view / contents that represent the component.
@@ -33,6 +32,6 @@ public function render(): View
3332
protected function exporters(): Collection
3433
{
3534
return Exportify::available()
36-
->when($this->tagged, fn(Collection $all) => $all->tagged($this->tagged));
35+
->when($this->tagged, fn (Collection $all) => $all->tagged($this->tagged));
3736
}
38-
}
37+
}

src/Concerns/ExportableCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public function tagged(string|array $tags): static
1616
$tags = Arr::wrap($tags);
1717

1818
return $this->filter(function (ExportFactory $factory) use ($tags) {
19-
19+
2020
$exportable = $factory->exportable();
2121

2222
return collect($exportable->tags())
2323
->intersect($tags)
2424
->isNotEmpty();
2525
});
2626
}
27-
}
27+
}

src/Contracts/ExportFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public function defaults(): array;
1515
* Make the exportable class using defaults and specified attributes.
1616
*
1717
* @param array<string, mixed> $attributes
18-
* @return Exportable
1918
*/
2019
public function exportable(array $attributes = []): Exportable;
2120

@@ -25,4 +24,4 @@ public function exportable(array $attributes = []): Exportable;
2524
* @return string|class-string
2625
*/
2726
public function livewire(): string;
28-
}
27+
}

src/Contracts/Exportable.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ interface Exportable
1010
* Download the export.
1111
*
1212
* @param array<string, mixed> $parameters
13-
* @return mixed
1413
*/
1514
public function download(array $parameters = []): mixed;
1615

src/Exceptions/ExportifyException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ public static function missingFactory(string $name): static
1313
{
1414
return new static(__('Export factory [:name] is not registered.', ['name' => $name]));
1515
}
16-
}
16+
}

src/Exportify.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class Exportify
1919

2020
/**
2121
* Get all registered exports.
22-
*
23-
* @return ExportableCollection
2422
*/
2523
public function all(): ExportableCollection
2624
{
@@ -29,8 +27,6 @@ public function all(): ExportableCollection
2927

3028
/**
3129
* Get all available exports for the current user.
32-
*
33-
* @return ExportableCollection
3430
*/
3531
public function available(): ExportableCollection
3632
{
@@ -61,10 +57,6 @@ public function find(string $name): ?ExportFactory
6157

6258
/**
6359
* Register a new export.
64-
*
65-
* @param string $name
66-
* @param ExportFactory $factory
67-
* @return void
6860
*/
6961
public function register(string $name, ExportFactory $factory): void
7062
{
@@ -73,9 +65,6 @@ public function register(string $name, ExportFactory $factory): void
7365

7466
/**
7567
* Unregister an export.
76-
*
77-
* @param string $name
78-
* @return void
7968
*/
8069
public function unregister(string $name): void
8170
{

src/ExportifyServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function configurePackage(Package $package): void
3636
public function packageRegistered(): void
3737
{
3838
$this->app->singleton('exportify', function ($app) {
39-
return new Exportify();
39+
return new Exportify;
4040
});
4141
}
4242
}

tests/Feature/Components/ExportableTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace BinaryCats\Exportify\Tests\Feature\Components;
44

5-
use BinaryCats\Exportify\Tests\Fixtures\FooExportFactory;
65
use BinaryCats\Exportify\Tests\Fixtures\ExportableLivewireFixture;
6+
use BinaryCats\Exportify\Tests\Fixtures\FooExportFactory;
77

8-
it('will_render_exportable_component', function(): void {
9-
10-
$factory = new FooExportFactory();
8+
it('will_render_exportable_component', function (): void {
9+
10+
$factory = new FooExportFactory;
1111

1212
$blade = $this->blade('<x-exportify-exportable :export-factory="$factory" />', ['factory' => $factory]);
13-
13+
1414
$blade->assertSeeLivewire(ExportableLivewireFixture::class);
15-
});
15+
});

0 commit comments

Comments
 (0)