Closed vcanales closed 4 weeks ago
This Pull Request refactors the them fonts class to improve code readability and maintainability. The main focus is on cleaning up the code.
I felt inclined to do this because when debugging for https://github.com/WordPress/create-block-theme/pull/660, I found some parts of the code hard to follow.
This PR addresses the need to make the code more readable and maintainable by:
Class documentation added: Added descriptions and the purpose of the CBT_Theme_Fonts class.
CBT_Theme_Fonts
Function improvements:
make_theme_font_src_absolute()
array_map
foreach
Code clean-up:
?? null
Function calls:
CBT_Theme_Fonts::
self::
Added test cases for parts of the code that could break on further refactors.
What?
This Pull Request refactors the them fonts class to improve code readability and maintainability. The main focus is on cleaning up the code.
I felt inclined to do this because when debugging for https://github.com/WordPress/create-block-theme/pull/660, I found some parts of the code hard to follow.
Why?
This PR addresses the need to make the code more readable and maintainable by:
How?
Key Changes:
Class documentation added: Added descriptions and the purpose of the
CBT_Theme_Fonts
class.Function improvements:
make_theme_font_src_absolute()
to usearray_map
for cleaner array handling.foreach
toarray_map
: This reduces the complexity and makes the handling of arrays cleaner.Code clean-up:
?? null
) for checking array keys.Function calls:
CBT_Theme_Fonts::
withself::
for static method calls within the class, enhancing readability and context awareness.Added test cases for parts of the code that could break on further refactors.