Skip to content

Commit

Permalink
Merge pull request #47 from nbayramberdiyev/master
Browse files Browse the repository at this point in the history
Drop Support for PHP 7.3 & Add Support for PHP 8.1
  • Loading branch information
freekmurze authored Dec 16, 2021
2 parents 4624f1d + e5b5df9 commit b54d54f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.0, 7.4, 7.3]
php: [8.1, 8.0, 7.4]
dependency-version: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ composer.lock
docs
vendor
tests/config.php
.phpunit.result.cache
.idea
.vscode
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
}
],
"require": {
"php" : "^7.3|^8.0",
"php" : "^7.4|^8.0",
"symfony/process": "^4.0|^5.0"
},
"require-dev": {
"phpunit/phpunit" : "^8.0|^9.0"
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 8 additions & 8 deletions src/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

class Pdf
{
protected $pdf;
protected string $pdf;

protected $binPath;
protected string $binPath;

protected $options = [];
protected array $options = [];

public function __construct(string $binPath = null)
public function __construct(?string $binPath = null)
{
$this->binPath = $binPath ?? '/usr/bin/pdftotext';
}
Expand Down Expand Up @@ -49,7 +49,7 @@ public function addOptions(array $options): self

protected function parseOptions(array $options): array
{
$mapper = function (string $content) : array {
$mapper = function (string $content): array {
$content = trim($content);
if ('-' !== ($content[0] ?? '')) {
$content = '-'.$content;
Expand All @@ -58,14 +58,14 @@ protected function parseOptions(array $options): array
return explode(' ', $content, 2);
};

$reducer = function (array $carry, array $option) : array {
$reducer = function (array $carry, array $option): array {
return array_merge($carry, $option);
};

return array_reduce(array_map($mapper, $options), $reducer, []);
}

public function text() : string
public function text(): string
{
$process = new Process(array_merge([$this->binPath], $this->options, [$this->pdf, '-']));
$process->run();
Expand All @@ -76,7 +76,7 @@ public function text() : string
return trim($process->getOutput(), " \t\n\r\0\x0B\x0C");
}

public static function getText(string $pdf, string $binPath = null, array $options = []) : string
public static function getText(string $pdf, ?string $binPath = null, array $options = []): string
{
return (new static($binPath))
->setOptions($options)
Expand Down

0 comments on commit b54d54f

Please sign in to comment.