mirror of
https://github.com/antonkomarev/github-profile-views-counter.git
synced 2026-07-22 21:43:45 -04:00
Add asserts to CounterFileRepository
This commit is contained in:
@@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||
namespace Komarev\GitHubProfileViewsCounter;
|
||||
|
||||
use Contracts\Komarev\GitHubProfileViewsCounter\CounterRepositoryInterface;
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class CounterFileRepository implements CounterRepositoryInterface
|
||||
{
|
||||
@@ -21,6 +22,14 @@ final class CounterFileRepository implements CounterRepositoryInterface
|
||||
|
||||
public function __construct(string $storagePath)
|
||||
{
|
||||
if (!is_dir($storagePath)) {
|
||||
throw new InvalidArgumentException('Counter storage is not a directory');
|
||||
}
|
||||
|
||||
if (!is_writable($storagePath)) {
|
||||
throw new InvalidArgumentException('Counter storage is not writable');
|
||||
}
|
||||
|
||||
$this->storagePath = $storagePath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user