Skip to content

Commit

Permalink
Merge pull request #14 from php-etl/feature/update-contracts
Browse files Browse the repository at this point in the history
Updated php-etl contract versions
  • Loading branch information
gplanchat committed Nov 22, 2023
2 parents 5002f3b + 0b75422 commit 9a70f6d
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 105 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/infection.yaml
Expand Up @@ -23,8 +23,8 @@ jobs:

- name: Infection
run: |
wget -q https://github.com/infection/infection/releases/download/0.26.18/infection.phar
wget -q https://github.com/infection/infection/releases/download/0.26.18/infection.phar.asc
wget -q https://github.com/infection/infection/releases/download/0.27.0/infection.phar
wget -q https://github.com/infection/infection/releases/download/0.27.0/infection.phar.asc
chmod +x infection.phar
./infection.phar
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/phpstan-5.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/phpstan-6.yaml
@@ -1,7 +1,7 @@
name: PHPStan level 6
on: push
jobs:
phpstan:
phpstan-6:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan-7.yaml
@@ -1,7 +1,7 @@
name: PHPStan level 7
on: push
jobs:
phpstan:
phpstan-7:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan-8.yaml
@@ -1,7 +1,7 @@
name: PHPStan level 8
on: push
jobs:
phpstan:
phpstan-8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/quality.yaml
@@ -1,4 +1,4 @@
name: Quality (PHPStan level 4)
name: Quality (PHPStan level 5)
on: push
jobs:
cs-fixer:
Expand Down Expand Up @@ -34,6 +34,6 @@ jobs:
uses: php-actions/phpstan@v3
with:
path: src/
level: 4
level: 5
php_version: '8.2'
php_extensions: zip xdebug
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -5,7 +5,7 @@ This package brings tools to read and write into spreadsheet files from a pipeli


[![Quality](https://github.com/php-etl/spreadsheet-flow/actions/workflows/quality.yaml/badge.svg)](https://github.com/php-etl/spreadsheet-flow/actions/workflows/quality.yaml)
[![PHPStan level 5](https://github.com/php-etl/spreadsheet-flow/actions/workflows/phpstan-5.yaml/badge.svg)](https://github.com/php-etl/spreadsheet-flow/actions/workflows/phpstan-5.yaml)
[![PHPStan level 6](https://github.com/php-etl/spreadsheet-flow/actions/workflows/phpstan-6.yaml/badge.svg)](https://github.com/php-etl/spreadsheet-flow/actions/workflows/phpstan-6.yaml)
[![PHPStan level 7](https://github.com/php-etl/spreadsheet-flow/actions/workflows/phpstan-7.yaml/badge.svg)](https://github.com/php-etl/spreadsheet-flow/actions/workflows/phpstan-7.yaml)
[![PHPStan level 8](https://github.com/php-etl/spreadsheet-flow/actions/workflows/phpstan-8.yaml/badge.svg)](https://github.com/php-etl/spreadsheet-flow/actions/workflows/phpstan-8.yaml)
![PHP](https://img.shields.io/packagist/php-v/php-etl/spreadsheet-flow)
Expand Down
43 changes: 15 additions & 28 deletions phpunit.xml
@@ -1,30 +1,17 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
backupGlobals="true"
colors="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
stopOnRisky="false"
timeoutForSmallTests="1"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="Functional tests">
<directory>tests/functional/</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<php>
<ini name="allow_url_include" value="1"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" backupGlobals="true" colors="false" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" stopOnRisky="false" timeoutForSmallTests="1" timeoutForMediumTests="10" timeoutForLargeTests="60" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Functional tests">
<directory>tests/functional/</directory>
</testsuite>
</testsuites>
<coverage/>
<php>
<ini name="allow_url_include" value="1"/>
</php>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
3 changes: 1 addition & 2 deletions src/CSV/FingersCrossed/Extractor.php
Expand Up @@ -18,8 +18,7 @@ public function __construct(
private ReaderInterface $reader,
private int $skipLines = 0,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function extract(): iterable
{
Expand Down
24 changes: 17 additions & 7 deletions src/CSV/FingersCrossed/Loader.php
Expand Up @@ -11,6 +11,7 @@
use Box\Spout\Writer\WriterInterface;
use Kiboko\Component\Bucket\AcceptanceResultBucket;
use Kiboko\Component\Bucket\EmptyResultBucket;
use Kiboko\Component\Bucket\RejectionResultBucket;
use Kiboko\Contract\Bucket\ResultBucketInterface;
use Kiboko\Contract\Pipeline\FlushableInterface;
use Kiboko\Contract\Pipeline\LoaderInterface;
Expand All @@ -22,29 +23,38 @@
public function __construct(
private WriterInterface $writer,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function load(): \Generator
{
$line = yield;
$line = yield new EmptyResultBucket();
try {
$this->writer->addRow(
new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null)
);
} catch (WriterNotOpenedException|IOException $exception) {
} catch (IOException|WriterNotOpenedException $exception) {
$this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]);

return;
$line = yield new RejectionResultBucket(
'Impossible to load data to the given CSV file.',
$exception,
$line
);
}

/* @phpstan-ignore-next-line */
while (true) {
try {
$this->writer->addRow(
new Row(array_map(fn ($value) => new Cell($value), $line), null)
);
} catch (WriterNotOpenedException|IOException $exception) {
} catch (IOException|WriterNotOpenedException $exception) {
$this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]);
$line = yield new RejectionResultBucket(
'Impossible to load data to the given CSV file.',
$exception,
$line
);
continue;
}

$line = yield new AcceptanceResultBucket($line);
Expand Down
3 changes: 1 addition & 2 deletions src/CSV/Safe/Extractor.php
Expand Up @@ -18,8 +18,7 @@ public function __construct(
private ReaderInterface $reader,
private int $skipLines = 0,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function extract(): iterable
{
Expand Down
24 changes: 17 additions & 7 deletions src/CSV/Safe/Loader.php
Expand Up @@ -11,6 +11,7 @@
use Box\Spout\Writer\WriterInterface;
use Kiboko\Component\Bucket\AcceptanceResultBucket;
use Kiboko\Component\Bucket\EmptyResultBucket;
use Kiboko\Component\Bucket\RejectionResultBucket;
use Kiboko\Contract\Bucket\ResultBucketInterface;
use Kiboko\Contract\Pipeline\FlushableInterface;
use Kiboko\Contract\Pipeline\LoaderInterface;
Expand All @@ -22,28 +23,37 @@
public function __construct(
private WriterInterface $writer,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function load(): \Generator
{
$line = yield;
$line = yield new EmptyResultBucket();
$headers = array_keys($line);
try {
$this->writer->addRow(
new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null)
);
} catch (WriterNotOpenedException|IOException $exception) {
} catch (IOException|WriterNotOpenedException $exception) {
$this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]);

return;
$line = yield new RejectionResultBucket(
'Impossible to load data to the given CSV file.',
$exception,
$line
);
}

/* @phpstan-ignore-next-line */
while (true) {
try {
$this->writer->addRow($this->orderColumns($headers, $line));
} catch (WriterNotOpenedException|IOException $exception) {
} catch (IOException|WriterNotOpenedException $exception) {
$this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]);
$line = yield new RejectionResultBucket(
'Impossible to load data to the given CSV file.',
$exception,
$line
);
continue;
}

$line = yield new AcceptanceResultBucket($line);
Expand Down
3 changes: 1 addition & 2 deletions src/Sheet/FingersCrossed/Extractor.php
Expand Up @@ -21,8 +21,7 @@ public function __construct(
private string $sheetName,
private int $skipLines = 0,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function extract(): iterable
{
Expand Down
21 changes: 16 additions & 5 deletions src/Sheet/FingersCrossed/Loader.php
Expand Up @@ -11,6 +11,7 @@
use Box\Spout\Writer\WriterInterface;
use Kiboko\Component\Bucket\AcceptanceResultBucket;
use Kiboko\Component\Bucket\EmptyResultBucket;
use Kiboko\Component\Bucket\RejectionResultBucket;
use Kiboko\Contract\Bucket\ResultBucketInterface;
use Kiboko\Contract\Pipeline\FlushableInterface;
use Kiboko\Contract\Pipeline\LoaderInterface;
Expand All @@ -30,25 +31,35 @@ public function __construct(

public function load(): \Generator
{
$line = yield;
$line = yield new EmptyResultBucket();

try {
$this->writer->addRow(
new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null)
);
} catch (WriterNotOpenedException|IOException $exception) {
} catch (IOException|WriterNotOpenedException $exception) {
$this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]);

return;
$line = yield new RejectionResultBucket(
'Impossible to load data to the given CSV file.',
$exception,
$line
);
}

/* @phpstan-ignore-next-line */
while (true) {
try {
$this->writer->addRow(
new Row(array_map(fn ($value) => new Cell($value), $line), null)
);
} catch (WriterNotOpenedException|IOException $exception) {
} catch (IOException|WriterNotOpenedException $exception) {
$this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]);
$line = yield new RejectionResultBucket(
'Impossible to load data to the given CSV file.',
$exception,
$line
);
continue;
}

$line = yield new AcceptanceResultBucket($line);
Expand Down
3 changes: 1 addition & 2 deletions src/Sheet/Safe/Extractor.php
Expand Up @@ -21,8 +21,7 @@ public function __construct(
private string $sheetName,
private int $skipLines = 0,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function extract(): iterable
{
Expand Down
21 changes: 16 additions & 5 deletions src/Sheet/Safe/Loader.php
Expand Up @@ -11,6 +11,7 @@
use Box\Spout\Writer\WriterInterface;
use Kiboko\Component\Bucket\AcceptanceResultBucket;
use Kiboko\Component\Bucket\EmptyResultBucket;
use Kiboko\Component\Bucket\RejectionResultBucket;
use Kiboko\Contract\Bucket\ResultBucketInterface;
use Kiboko\Contract\Pipeline\FlushableInterface;
use Kiboko\Contract\Pipeline\LoaderInterface;
Expand All @@ -30,23 +31,33 @@ public function __construct(

public function load(): \Generator
{
$line = yield;
$line = yield new EmptyResultBucket();
$headers = array_keys($line);
try {
$this->writer->addRow(
new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null)
);
} catch (WriterNotOpenedException|IOException $exception) {
} catch (IOException|WriterNotOpenedException $exception) {
$this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]);

return;
$line = yield new RejectionResultBucket(
'Impossible to load data to the given CSV file.',
$exception,
$line
);
}

/* @phpstan-ignore-next-line */
while (true) {
try {
$this->writer->addRow($this->orderColumns($headers, $line));
} catch (WriterNotOpenedException|IOException $exception) {
} catch (IOException|WriterNotOpenedException $exception) {
$this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]);
$line = yield new RejectionResultBucket(
'Impossible to load data to the given CSV file.',
$exception,
$line
);
continue;
}

$line = yield new AcceptanceResultBucket($line);
Expand Down

0 comments on commit 9a70f6d

Please sign in to comment.