-
-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ConvertTime Class with Time Conversion Functionality and Unit Tests #177
base: master
Are you sure you want to change the base?
Add ConvertTime Class with Time Conversion Functionality and Unit Tests #177
Conversation
// Example usage | ||
try { | ||
$timeResult = convertTime(120, 'minutes', 'seconds'); | ||
echo "120 minutes = $timeResult seconds\n"; | ||
} catch (InvalidArgumentException $e) { | ||
echo "Error: " . $e->getMessage() . "\n"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep examples like this in the test code, with assertions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Example usage | ||
try { | ||
$timeResult = convertTime(120, 'minutes', 'seconds'); | ||
echo "120 minutes = $timeResult seconds\n"; | ||
} catch (InvalidArgumentException $e) { | ||
echo "Error: " . $e->getMessage() . "\n"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these 7 lines of code from ConvertTime.php
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.Unit Tests:
The
ConvertTimeTest
class covers the following:from
andto
units with descriptive error messages.This addition enhances functionality by enabling easy and accurate time conversions while ensuring reliability through comprehensive testing.