This PR addresses the issue of improving the modularity of the GedcomExporter class. The handle method in GedcomExporter was doing several things, making it hard to read and maintain. This PR breaks down the handle method into smaller, more manageable methods, each with a single responsibility.
Summary of Changes
Created a new helper class GedcomExporterHelpers in src/Commands/GedcomExporterHelpers.php that contains methods for directory creation, database querying, data preparation for the view, GEDCOM document string creation, and file writing.
Refactored the handle method in GedcomExporter to use these new helper methods.
The handle method now calls these helper methods and uses their return values as needed, making the code more readable and maintainable.
This refactor enhances the separation of concerns within the codebase and aligns with best practices in software development.
PR Feedback (click)
I created this PR to address this rule:
"Refactor large functions to be more modular."
Description
This PR addresses the issue of improving the modularity of the
GedcomExporter
class. Thehandle
method inGedcomExporter
was doing several things, making it hard to read and maintain. This PR breaks down thehandle
method into smaller, more manageable methods, each with a single responsibility.Summary of Changes
GedcomExporterHelpers
insrc/Commands/GedcomExporterHelpers.php
that contains methods for directory creation, database querying, data preparation for the view, GEDCOM document string creation, and file writing.handle
method inGedcomExporter
to use these new helper methods.handle
method now calls these helper methods and uses their return values as needed, making the code more readable and maintainable.This refactor enhances the separation of concerns within the codebase and aligns with best practices in software development.