Repository navigation
Layer the code as actions, services and support - #8
Merged
Merged
Conversation
Support\Json (the package's JSON flags and its encode error) and Support\Translations (the lang/json title format) replace the copies in CategoryRepository, SyncDefinitions, DatabaseDefinitions, DatabaseAuditSink and the category factory. DatabaseDefinitions::localised() stays and forwards, deprecated.
DatabaseValues::boolean() replaces five copies of the [true, 1, '1'] check. Scope gains of(), fromString() and owner(), which replace the scope parsing copied in DatabaseDriver, RecordSerializer and QueryAudit and the owner-to-scope helpers in SettingsManager and SettingWriter. Behaviour is unchanged: a malformed stored scope still raises each caller's DriverFailure, an invalid alias still raises InvalidIdentifier.
The provider's lenient string, integer, array and strings readers and StoreRegistry's strict list-of-strings check now live in one class; their call sites and messages are unchanged.
DatabaseAuditSink, QueryAudit and PruneAudit no longer build queries on the audit table; the row format, tenant filter, store fallback and prune live in Database\AuditRepository. Moved verbatim; behaviour is unchanged.
SyncDefinitions keeps the authorization, the per-store loop and the audit entry; the upsert, conflict check, removal and runtime-row query move verbatim to Database\DefinitionsRepository, which DatabaseDefinitions reads through too.
doctor's column, id-type and cross-store category checks and install's foreign-table check read the database through Database\SchemaInspector instead of the schema builder directly. A failed introspection still reports nothing rather than a finding.
The stancl and spatie adapters and the auto/null/class choice move out of the service provider verbatim; the provider only binds the result.
PromoteStore, CategoryGuard and CategoryManager each looked the layer up and built the same StoreNotWritable message; they now share one method, and CategoryRepository::of() builds a store's repository. Messages are unchanged.
WriteGuard, CategoryGuard and PromoteStore each wrapped their work in the same transaction, allowed-entry, rollback, failed-entry, rethrow sequence. Support\AuditedTransaction is that sequence once; the three keep their constructors, their public methods and their audit entries (actions, outcomes, versions, meta and reasons are unchanged).
PruneOrphans had two public intents. FindOrphans::handle() finds (moved verbatim) and PruneOrphans::handle() removes what it finds; PruneOrphans::find() stays, deprecated, and forwards. The prune-orphans command lists through FindOrphans.
Arch tests: an action's only public method is handle(); actions do not touch the connection or schema builder; only entry points import actions; support classes are readonly. Each exemption names its reason and fails when stale; each scan asserts how many files it read. RecordSerializer and ValueEncoder, which hold no state, are declared readonly.
Under --parallel Pest honours only the first --exclude-group, and the comma-separated --exclude-group=matrix,shared-app excluded nothing, so the tests that publish into the shared testbench application raced the others on config/laranail/settings.php (reproduced locally in 2 runs of 3). Both groups now also carry group mutation-excluded, which the job excludes; the run is 433 tests, stable over repeated parallel runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This lays the code out as entry points → actions → services → support, following the plan written from an inventory of
src/. Behaviour, messages and audit entries are unchanged, and nothing public is removed.Support (one implementation of duplicated logic):
JsonandTranslationsreplace 5 copies of the title/JSON encoding.DatabaseValues::boolean()replaces 5 copies of the[true, 1, '1']check.Scope::of(),Scope::fromString()andScope::owner()replace 7 copies of scope parsing.ConfigValuescollects the provider's typed config readers and the strict list check.AuditedTransactionis the single implementation of: transaction, allowed entry, rollback, failed entry, rethrow. Every write, category change and promotion uses it.Services (database work moved out of actions):
Database\AuditRepositorytakes the audit sink, query and prune.Database\DefinitionsRepositorytakes the definitions sync and reads.Database\SchemaInspectortakesdoctorand install's foreign-table check.Tenancy\TenantDiscriminatorstakes the stancl and spatie adapters, out of the service provider.Store::requireDatabase()andCategoryRepository::of()replace three copies of the same lookup and error.Actions:
FindOrphanssplit fromPruneOrphans.Guards: architecture tests check that:
handle();Every exemption states its reason and fails if it goes stale. Every scan checks it read at least a minimum number of files. All five failure modes were proven red.
Deprecated (both still work and forward)
PruneOrphans::find()→FindOrphans::handle()(removal: 1.0)DatabaseDefinitions::localised()→Translations::nullableText()(removal: 1.0). It differs only for a malformed JSON map whose''entry is not a string.Kept on purpose
WriteGuardandCategoryGuardstay inActions/and delegate toAuditedTransaction. Each still holds its own logic (approval and lock override; repository and events), so moving them would only rename public classes.QueryAuditstays an action. It is now authorize +AuditRepository, and splitting its three result shapes would change public signatures.SettingsManager,DatabaseDriver, the provider) are not split by size alone.Testing
vendor/bin/pest: 465 passed. Coverage 97.5%. PHPStan at max level: no errors. Rector and Pint are clean. MySQL and PostgreSQL run in CI.