Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate ValinorConfigFactory and make cuyz/valinor optional #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ on:
jobs:
ci:
uses: shlinkio/github-actions/.github/workflows/php-lib-ci.yml@main
with:
coverage-driver: 'xdebug'
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
* *Nothing*

### Changed
* Switch to xdebug for code coverage reports, as pcov is not marking functions as covered
* Switch to xdebug for code coverage reports, as pcov is not marking functions as covered.
* Make `cuyz/valinor` an optional dependency, required only if you plan to use `ValinorConfigFactory`.

### Deprecated
* *Nothing*
* Deprecate `ValinorConfigFactory`.

### Removed
* *Nothing*
Expand Down
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,3 @@ Install this tool using [composer](https://getcomposer.org/).
* `loadConfigFromGlob`: Function which expects a glob pattern and loads and merges all config files that match it.
* `EnvVarLoaderProvider`: A config provider which loads the entries of the loaded config into env vars and always returns empty. Designed to be the first config provider in the pipeline.
* `DottedAccessConfigAbstractFactory`: An abstract factory that lets any config param to be fetched as a service by using the `config.foo.bar` notation.
* `ValinorConfigFactory`: A PSR-11 factory that lets you map arbitrary objects from arrays, using [cuyz/valinior](https://github.com/CuyZ/Valinor).

In order to use it, you have to register the object to map as a service, and the ValinorConfigFactory with static access using the service that returns the raw array with the data as the static method name:

```php
<?php

declare(strict_types=1);

return [
MyCoolOptions::class => [ValinorConfigFactory::class, 'config.foo.options'],
];
```

It is useful to combine this factory with the `DottedAccessConfigAbstractFactory`.

The mapping will be done with cache if a `Psr\SimpleCache\CacheInterface` service is found.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
],
"require": {
"php": "^8.2",
"cuyz/valinor": "^1.12",
"laminas/laminas-config": "^3.9",
"laminas/laminas-servicemanager": "^4.2 || ^3.22"
},
"suggest": {
"cuyz/valinor": "To be able to use ValinorConfigFactory"
},
"require-dev": {
"cuyz/valinor": "^1.12",
"devster/ubench": "^2.1",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^11.3",
Expand Down
1 change: 1 addition & 0 deletions src/Factory/ValinorConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Psr\Container\ContainerInterface;
use Psr\SimpleCache\CacheInterface;

/** @deprecated */
class ValinorConfigFactory
{
public static function __callStatic(string $name, array $arguments): mixed
Expand Down