From 3a5411f8585e0de8f4783f175010af1d96ebb119 Mon Sep 17 00:00:00 2001 From: Olivier Gorzalka Date: Wed, 7 Oct 2026 09:50:36 +0200 Subject: [PATCH 1/3] docs: refresh the README --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index db9eb2c..12584a3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ -# Pollora Option +

+ + Pollora Option: validated WordPress options with a small static API + +

-A modern PHP package for WordPress option management with validation and immutable value objects. +

+ Latest version + Total downloads + Tests + License +

+ +A dependency-free PHP wrapper around the WordPress options API. Keys and values are validated before they reach the database, `set()` creates or updates in one call, and options are modeled as immutable value objects, so a typo'd key or an unserializable value fails loudly instead of being stored silently. + +> Part of [Pollora](https://pollora.dev), the Laravel framework for WordPress. In a Pollora project it is already installed: use the `Pollora\Support\Facades\Option` facade instead. The standalone class emits a notice when the framework is present. ## Installation @@ -8,31 +21,50 @@ A modern PHP package for WordPress option management with validation and immutab composer require pollora/option ``` -## Quick Start +Requires PHP 8.2+ and WordPress (the adapter calls `get_option()`, `add_option()`, `update_option()` and `delete_option()`). + +## Quick start ```php use Pollora\Option\Option; -// Get with default -$value = Option::get('site_title', 'My Site'); +// Read, with a default when the option does not exist +$title = Option::get('site_title', 'My Site'); -// Smart upsert (creates or updates) +// Create or update (smart upsert) Option::set('site_title', 'New Title'); -// Check existence +// Update an existing option +Option::update('posts_per_page', 20); + +// Check, then delete if (Option::exists('api_key')) { Option::delete('api_key'); } - -// Update existing -Option::update('posts_per_page', 20); ``` -> **Pollora framework users:** When the framework is available, prefer the Laravel facade `Pollora\Support\Facades\Option` for full DI container support. A notice is emitted if you use the standalone class within the framework. +## What you get + +- **Five static methods**: `get()`, `set()`, `update()`, `delete()`, `exists()`; writes return `bool`. +- **Key validation**: 1 to 191 characters, no null bytes, otherwise `InvalidOptionException`. +- **Value validation**: resources and objects that cannot be serialized (closures, for instance) are refused before reaching WordPress. +- **Immutable value object**: `Domain\Model\Option` carries `key`, `value` and `autoload`, derived with `withValue()` and `withAutoload()`. +- **Hexagonal core**: `OptionService` works against an `OptionRepositoryInterface` port; `WordPressOptionRepository` is the WordPress adapter, and you can swap it in tests. + +```php +use Pollora\Option\Domain\Exception\InvalidOptionException; + +try { + Option::set('', 'value'); +} catch (InvalidOptionException $e) { + // "Option key cannot be empty" +} +``` ## Documentation -See [docs/options.md](docs/options.md) for full documentation. +- [docs/options.md](docs/options.md): the service, value objects, validation and error handling. +- Options in a Pollora project: [Options](https://pollora.dev/content/options/). ## Testing @@ -40,6 +72,10 @@ See [docs/options.md](docs/options.md) for full documentation. composer test ``` +## Contributing + +Contributions are welcome: see the [contributing guide](https://github.com/Pollora/.github/blob/main/CONTRIBUTING.md). Report security issues privately, as described in the [security policy](https://github.com/Pollora/.github/blob/main/SECURITY.md). + ## License -MIT — see [LICENSE](LICENSE). +Pollora Option is open-source software licensed under the [MIT license](LICENSE). © [RuBee group](https://rubee.group) From 45b0b4507caa6d08cce4969cc7f6aa014fb93f0d Mon Sep 17 00:00:00 2001 From: Olivier Gorzalka Date: Wed, 7 Oct 2026 09:50:36 +0200 Subject: [PATCH 2/3] chore: link the RuBee group in the license holder line --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 4c0ea40..bc3cb93 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 RuBee group +Copyright (c) 2025 RuBee group (https://rubee.group) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 7d7e47eed6177c5fd6f23f98ddb8652b32f5c542 Mon Sep 17 00:00:00 2001 From: Olivier Gorzalka Date: Wed, 7 Oct 2026 10:11:55 +0200 Subject: [PATCH 3/3] docs: PHP 8.3+, as the fix in #2 requires --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 12584a3..d83aa07 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ A dependency-free PHP wrapper around the WordPress options API. Keys and values composer require pollora/option ``` -Requires PHP 8.2+ and WordPress (the adapter calls `get_option()`, `add_option()`, `update_option()` and `delete_option()`). +Requires PHP 8.3+ and WordPress (the adapter calls `get_option()`, `add_option()`, `update_option()` and `delete_option()`). ## Quick start