Skip to content

04: Config facade - #4

Open
nikolaystrikhar wants to merge 3 commits into
mainfrom
04-config
Open

04: Config facade#4
nikolaystrikhar wants to merge 3 commits into
mainfrom
04-config

Conversation

@nikolaystrikhar

Copy link
Copy Markdown
Contributor

What: Config static facade — hook prefix, version, optional container — plus Config_Exception.

Usage:

Config::set_hook_prefix( "give" );
Config::set_container( give()->container ); // optional

Why this way: the plan sketched a bare RuntimeException; this throws Config_Exception extends RuntimeException, so the documented contract still holds and callers get one catchable type across the library. set_hook_prefix() validates eagerly rather than at use, because a bad prefix otherwise surfaces as a silently-never-firing filter much later. It also rejects the empty string, which the character-class check alone would accept — that would resurface at get_hook_prefix() as the misleading "you must call set_hook_prefix()" long after the real mistake.

lucatume\DI52\Container implements PSR-11's ContainerInterface, not StellarWP's, so the tests configure the facade through Tests\Support\Test_Container — a thin adapter modelled on the contract package's own di52 example. Config::set_container()'s signature is unchanged: the StellarWP contract stays the public API, and stellarwp/container-contract remains the only production dependency.

Verify: slic run unit — 19 tests, 28 assertions, green. Covers the validation regex, the empty-prefix and unset-prefix throws, the RuntimeException catchability, container storage, and reset(). get_version() is stored but not yet read by anything; see the spec's known-issue F.

…tate

- Assert Config_Exception is catchable as RuntimeException; nothing covered
  that inheritance, so dropping it would have left the suite green.
- Reset Config in setUp() as well as tearDown(), so the tests asserting on
  default state no longer depend on class execution order.
- Note that the container fixture inherits DI52's class_exists() fallback
  in has().
- Drop a README pointer to a section that does not exist yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant