Skip to content

Commit

Permalink
Rename FailingProvider as RestrictedProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Aug 10, 2024
1 parent 0f57020 commit e6360ed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,19 @@ Use [the cldr command][] to warm up the CLDR cache:
```

The following example demonstrates how a repository can be instantiated with a restrictive provider
that uses warmed-up data only. With this configuration, the [FailingProvider][] throws an exception
that uses warmed-up data only. With this configuration, the [RestrictedProvider][] throws an exception
if the data is not available in the cache.

```php
<?php

use ICanBoogie\CLDR\Cache\FileCache;
use ICanBoogie\CLDR\Provider\CachedProvider;
use ICanBoogie\CLDR\Provider\FailingProvider;
use ICanBoogie\CLDR\Provider\RestrictedProvider;
use ICanBoogie\CLDR\Repository;

$provider = new CachedProvider(
new FailingProvider(),
new RestrictedProvider(),
new FileCache(FileCache::RECOMMENDED_DIR),
);

Expand Down Expand Up @@ -256,7 +256,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) for details.
[FileCache]: src/Cache/FileCache.php
[Provider]: src/Provider.php
[WebProvider]: src/Provider/WebProvider.php
[FailingProvider]: src/Provider/FailingProvider.php
[RestrictedProvider]: src/Provider/RestrictedProvider.php
[Repository]: src/Repository.php

[2]: https://github.com/unicode-cldr
Expand Down
19 changes: 0 additions & 19 deletions src/Provider/FailingProvider.php

This file was deleted.

19 changes: 19 additions & 0 deletions src/Provider/RestrictedProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace ICanBoogie\CLDR\Provider;

use ICanBoogie\CLDR\Provider;
use ICanBoogie\CLDR\ResourceNotFound;

/**
* A {@see Provider} that fails to provide any path.
*
* This provider restricts the usage of the repository to cached data.
*/
final class RestrictedProvider implements Provider
{
public function provide(string $path): array
{
throw new ResourceNotFound("Only cached data is available, tried to read from: $path");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace Test\ICanBoogie\CLDR\Provider;

use ICanBoogie\CLDR\Provider\FailingProvider;
use ICanBoogie\CLDR\Provider\RestrictedProvider;
use ICanBoogie\CLDR\ResourceNotFound;
use PHPUnit\Framework\TestCase;

/**
* @group static
*/
class FailingProviderTest extends TestCase
class RestrictedProviderTest extends TestCase
{
public function test_provide(): void
{
$sut = new FailingProvider();
$sut = new RestrictedProvider();

$this->expectException(ResourceNotFound::class);
$this->expectExceptionMessageMatches("/Only warmed-up data is available/");
$this->expectExceptionMessageMatches("/Only cached data is available/");

$sut->provide("foo");
}
Expand Down

0 comments on commit e6360ed

Please sign in to comment.