Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Jul 25, 2024
1 parent 824fb21 commit 0ab8dbd
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 66 deletions.
1 change: 0 additions & 1 deletion .idea/linen.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
},
"extra": {
"laravel": {
"providers": [
"Glhd\\Linen\\Support\\LinenServiceProvider"
]
"providers": []
}
},
"minimum-stability": "dev",
Expand Down
2 changes: 1 addition & 1 deletion src/CsvReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function castCell(Cell $cell): mixed
{
$value = $cell->getValue();

return match(true) {
return match (true) {
is_numeric($value) => (float) $value == (int) $value ? (int) $value : (float) $value,
'' === $value => null,
default => $value,
Expand Down
7 changes: 2 additions & 5 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Glhd\Linen;

use DateInterval;
use DateTimeInterface;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Illuminate\Support\Str;
Expand All @@ -17,8 +15,6 @@
/** @extends IteratorAggregate<int, Collection> */
abstract class Reader implements IteratorAggregate
{
abstract protected function reader(): ReaderInterface;

public static function from(string $path): static
{
return new static($path);
Expand Down Expand Up @@ -52,7 +48,6 @@ public function collect(): LazyCollection

foreach ($sheet->getRowIterator() as $row) {
/** @var \OpenSpout\Common\Entity\Row $row */

if (null === $keys) {
$keys = array_map($this->headerToKey(...), $row->toArray());
$columns = count($keys);
Expand Down Expand Up @@ -80,6 +75,8 @@ public function collect(): LazyCollection
});
}

abstract protected function reader(): ReaderInterface;

protected function castRow(Row $data): array
{
return array_map($this->castCell(...), $data->getCells());
Expand Down
2 changes: 1 addition & 1 deletion src/Support/FileTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function write(array|Enumerable|Generator|Builder $data, string $path): s
{
$extension = pathinfo($path, PATHINFO_EXTENSION);

$writer = match($extension) {
$writer = match ($extension) {
'xlsx', 'xls' => ExcelWriter::for($data),
'csv' => CsvWriter::for($data),
default => throw new InvalidArgumentException("Unable to infer file type for '{$path}'"),
Expand Down
34 changes: 0 additions & 34 deletions src/Support/LinenServiceProvider.php

This file was deleted.

7 changes: 0 additions & 7 deletions src/Support/helpers.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ abstract class Writer

protected Closure $header_formatter;

abstract protected function writer(): WriterInterface;

public static function for(array|Enumerable|Generator|Builder $data): static
{
return new static($data);
Expand Down Expand Up @@ -83,6 +81,8 @@ public function writeToTemporaryFile(): string
return $this->write($path);
}

abstract protected function writer(): WriterInterface;

/** @return Generator<Collection> */
protected function rows(): Generator
{
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/CsvWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Feature;

use Glhd\Linen\CsvReader;
use Glhd\Linen\CsvWriter;
use Glhd\Linen\Tests\TestCase;

Expand Down
1 change: 0 additions & 1 deletion tests/Feature/ExcelReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Feature;

use Glhd\Linen\CsvReader;
use Glhd\Linen\ExcelReader;
use Glhd\Linen\Tests\TestCase;

Expand Down
1 change: 0 additions & 1 deletion tests/Feature/ExcelWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Feature;

use Glhd\Linen\CsvWriter;
use Glhd\Linen\ExcelReader;
use Glhd\Linen\ExcelWriter;
use Glhd\Linen\Tests\TestCase;
Expand Down
4 changes: 0 additions & 4 deletions tests/Feature/FacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

namespace Feature;

use Glhd\Linen\CsvReader;
use Glhd\Linen\CsvWriter;
use Glhd\Linen\ExcelReader;
use Glhd\Linen\ExcelWriter;
use Glhd\Linen\Facades\Linen;
use Glhd\Linen\Tests\TestCase;
use Illuminate\Support\Facades\App;

class FacadeTest extends TestCase
{
Expand Down
6 changes: 1 addition & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Glhd\Linen\Tests;

use Glhd\Linen\Support\LinenServiceProvider;
use Illuminate\Container\Container;
use Orchestra\Testbench\TestCase as Orchestra;

abstract class TestCase extends Orchestra
Expand All @@ -15,9 +13,7 @@ protected function fixture(string $filename): string

protected function getPackageProviders($app)
{
return [
LinenServiceProvider::class,
];
return [];
}

protected function getPackageAliases($app)
Expand Down

0 comments on commit 0ab8dbd

Please sign in to comment.