Skip to content

Commit

Permalink
feat: add constructor with check
Browse files Browse the repository at this point in the history
  • Loading branch information
loks0n committed Oct 17, 2024
1 parent ae427de commit 30899e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Compression/Algorithms/LZ4.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class LZ4 extends Compression

public function __construct(int $level = 0)
{
parent::__construct();
$this->level = $level;
}

Expand Down
1 change: 1 addition & 0 deletions src/Compression/Algorithms/Zstd.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Zstd extends Compression

public function __construct(int $level = 3)
{
parent::__construct();
$this->level = $level;
}

Expand Down
7 changes: 7 additions & 0 deletions src/Compression/Compression.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ abstract class Compression

public const ZSTD = 'zstd';

public function __construct()
{
if (!self::isSupported()) {
throw new \Exception('Compression algorithm' . $this->getName() . ' is not supported, missing extension');
}
}

/**
* Return the name of compression algorithm.
*
Expand Down

0 comments on commit 30899e3

Please sign in to comment.