Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

PeteBishwhip
Copy link
Member

@PeteBishwhip PeteBishwhip commented Mar 25, 2025

This pull request focuses on refactoring the code to use a new Environment class for determining the operating system, improving readability and maintainability. The most important changes include the introduction of the Environment class and its integration into existing methods.

Introduction of the Environment class:

  • src/Support/Environment.php: Added a new Environment class with methods to check the current operating system (isWindows, isLinux, isMac, isUnknown, isUnixLike).

Integration of the Environment class:

  • src/Commands/DebugCommand.php: Replaced checks for PHP_OS_FAMILY with calls to the new Environment class methods in processEnvironment and outputToClipboard functions. [1] [2]
  • src/System.php: Updated the timezone function to use Environment::isWindows instead of checking PHP_OS_FAMILY.

Additional updates to import the Environment class:

@PeteBishwhip PeteBishwhip marked this pull request as ready for review March 25, 2025 14:59
@PeteBishwhip
Copy link
Member Author

The addition of the Environment class helper allows us to provide known ways of identifying things in the environment which may affect workflows dependent on the system NativePHP is running on.

To begin with, I have added the Operating Systems and this demonstrates how now we can use one point of truth without many different methods of checking for the same result.

This can be extended out as needs emerge.

@SRWieZ SRWieZ self-requested a review March 26, 2025 13:55
Copy link
Member

@simonhamp simonhamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

@simonhamp simonhamp merged commit fe865fe into main Mar 27, 2025
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.

3 participants