This report summarizes architecture and maintainability opportunities identified by reviewing core runtime/orchestration, parsing, metadata compilation, and project setup.
PaisleyPark::segue()currently mixes control flow, validation rules, and user-facing error accumulation into one very large method.- Recommendation: split into stage-oriented services (
EbookValidator,TextValidator,AssetValidator,BuildPipeline) and return structured result objects. - Benefit: easier feature additions (new rules), more isolated tests, fewer regressions from editing one giant method.
- Runtime options are currently stored in
Girlfriend::$memoryas mutable string flags (yes/no, string paths). - Recommendation: replace with immutable typed options (
BuildOptions) parsed once from CLI and passed through dependency graph. - Benefit: compile-time guarantees, fewer hidden global side effects, simpler testing.
Girlfriendacts as logger, config store, path registry, utility collection, and singleton lifecycle manager.- Recommendation: extract interfaces/services (
PathResolver,MessageBus,StringNormalizer,FileSystem) and inject dependencies into orchestrators. - Benefit: clearer responsibilities and easier unit testing without global state resets.
- Errors are currently message-template driven in
Affirmation, useful for humans but hard for automation. - Recommendation: add stable error codes and structured payloads (JSON output mode, severity enum, source location).
- Benefit: CI integration, IDE tooling, scriptable quality gates.
- XML parsing and extraction responsibilities are centralized in
XMLetsGoCrazywith broad static methods. - Recommendation: separate parser (
LeaXmlParser) from domain extractors, define small method contracts per entity type. - Benefit: easier validation evolution (schema checks, stricter attribute handling, better namespace extensibility).
- Project currently appears to have no
tests/suite despiteautoload-devmapping and rich domain behavior. - Recommendation: add PHPUnit/Pest tests across:
- identifier normalization/transliteration,
- XPath extraction and malformed input handling,
- OPF/manifest/spine generation snapshots,
- URL checker behavior (mocked HTTP),
- end-to-end compile fixtures from
arx/ebookssamples.
- Benefit: safer refactoring velocity and release confidence.
- Recommendation: add CI workflow with minimum gates: lint, unit tests, static analysis, and a fixture build.
- Suggested tools:
php -lfor syntax,- PHPStan/Psalm for static analysis,
- PHP-CS-Fixer or Pint for formatting.
- Benefit: consistency and early defect detection.
composer.jsonpinsphpto^8.5, which is very forward-leaning and may limit adoption.- Recommendation: validate minimum required language features and consider broadening compatibility if possible.
- Benefit: easier installation and contributor onboarding.
- OPF/manifest/spine metadata assembly uses large string concatenation logic.
- Recommendation: switch to XML DOM builders or dedicated template renderers with escaping guarantees.
- Benefit: lower risk of malformed XML and better readability.
- README already notes intent to check extension availability.
- Recommendation: central
EnvironmentPreflightcheck (curl, zip, dom, filesystem permissions, EPUBCheck binaries) with actionable diagnostics. - Benefit: faster troubleshooting and better UX for new users.
- Testing scaffold + baseline fixtures
- Error codes + structured diagnostics
- Options/config refactor (remove mutable global memory)
- Pipeline decomposition (validator/build stages)
- XML/domain extraction service split
- CI/static analysis hardening
This sequence maximizes safety before deeper refactors.