PHP icon indicating copy to clipboard operation
PHP copied to clipboard

Add ConvertTime Class with Time Conversion Functionality and Unit Tests

Open arafat-web opened this issue 1 year ago • 0 comments

Description:
This pull request introduces the ConvertTime class, providing a robust time conversion function alongside a complete suite of unit tests to ensure accurate and reliable operation.

Key Features:

  • convertTime Function: Converts a specified value between various time units (e.g., seconds, minutes, hours, days, weeks, months, and years) using predefined conversion factors.
  • Exception Handling: Throws clear exceptions for invalid input units, enhancing user feedback and preventing errors.
  • PSR-12 Compliance: The code adheres to PSR-12 standards, ensuring readability and maintainability.

Unit Tests:

The ConvertTimeTest class covers the following:

  • Basic Conversion Tests: Verifies correct conversions between time units.
  • Edge Case Handling: Tests zero-value conversions for non-negative results.
  • Invalid Unit Handling: Tests exception handling for invalid from and to units with descriptive error messages.

This addition enhances functionality by enabling easy and accurate time conversions while ensuring reliability through comprehensive testing.

arafat-web avatar Oct 30 '24 17:10 arafat-web