{"id":15150392,"url":"https://github.com/othyn/php-time-remaining","last_synced_at":"2026-01-23T16:35:51.157Z","repository":{"id":251747789,"uuid":"838301281","full_name":"othyn/php-time-remaining","owner":"othyn","description":"A really simple PHP Composer package to calculate and format time remaining/progress.","archived":false,"fork":false,"pushed_at":"2024-08-14T15:22:34.000Z","size":221,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-19T16:46:30.761Z","etag":null,"topics":["composer","estimates","package","php","progress","time-tracking"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/othyn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-05T11:12:46.000Z","updated_at":"2024-08-14T15:20:51.000Z","dependencies_parsed_at":"2024-08-05T14:07:01.235Z","dependency_job_id":"7640446f-9720-45c6-834f-49dafd1b9a13","html_url":"https://github.com/othyn/php-time-remaining","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"cf6ff9e4752920d2b28b6a518118307463f7f32a"},"previous_names":["othyn/php-time-remaining"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/othyn/php-time-remaining","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othyn%2Fphp-time-remaining","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othyn%2Fphp-time-remaining/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othyn%2Fphp-time-remaining/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othyn%2Fphp-time-remaining/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/othyn","download_url":"https://codeload.github.com/othyn/php-time-remaining/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/othyn%2Fphp-time-remaining/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28695579,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T15:57:05.722Z","status":"ssl_error","status_checked_at":"2026-01-23T15:56:27.656Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","estimates","package","php","progress","time-tracking"],"created_at":"2024-09-26T14:03:34.044Z","updated_at":"2026-01-23T16:35:51.118Z","avatar_url":"https://github.com/othyn.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Time Remaining\n\n[![Tests](https://github.com/othyn/php-time-remaining/actions/workflows/phpunit.yml/badge.svg)](https://github.com/othyn/php-time-remaining/actions/workflows/phpunit.yml)\n[![Code Style](https://github.com/othyn/php-time-remaining/actions/workflows/phpcsfixer.yml/badge.svg)](https://github.com/othyn/php-time-remaining/actions/workflows/phpcsfixer.yml)\n[![Downloads](https://img.shields.io/packagist/dt/othyn/php-time-remaining?color=green)](#installation)\n[![GitHub license](https://img.shields.io/github/license/othyn/php-time-remaining)](https://github.com/othyn/php-time-remaining/blob/main/LICENSE)\n[![Love](https://img.shields.io/badge/built%20with-love-red)](https://img.shields.io/badge/built%20with-love-red)\n\nA [Composer](https://getcomposer.org/) package for [PHP](https://www.php.net/) that adds a seriously simple progress tracker, with a focus on estimating completion time.\n\n```php\n\u003c?php\n\nuse Othyn\\TimeRemaining\\TimeRemaining;\n\n$timeRemaining = new TimeRemaining(100);\nsleep(30); // Simulate some work being done.\n\n$formattedProgress = $timeRemaining-\u003egetFormattedProgress(50);\necho $formattedProgress; // Output: [50% - 50 / 100][~ 0h 0m 30s remaining]\n```\n\nThe package is available on Packagist as [othyn/php-time-remaining](https://packagist.org/packages/othyn/php-time-remaining).\n\n---\n\n## Installation\n\nHop into your project that you wish to install it in and run the following Composer command to grab the latest version:\n\n```sh\ncomposer require othyn/php-time-remaining\n```\n\n---\n\n## Usage\n\nFor more comprehensive usage examples, you can view the test suite. However I'll show some basic usage examples below.\n\n### Initialisation\n\nTo start using the `TimeRemaining` package, initialise it with the total number of items required:\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse Othyn\\TimeRemaining\\TimeRemaining;\n\n$totalItems = 100;\n$timeRemaining = new TimeRemaining($totalItems);\n```\n\nYou can also later update the total amount of items if you cannot define it at the point of initialisation:\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse Othyn\\TimeRemaining\\TimeRemaining;\n\n$timeRemaining = new TimeRemaining();\n\n// Code that fetches total items as $totalItems\n\n$timeRemaining-\u003esetTotalItems($totalItems);\n```\n\n### Formatting the Output\n\nTo get a formatted string showing the progress and remaining time:\n\n```php\n\u003c?php\n\n$formattedProgress = $timeRemaining-\u003egetFormattedProgress($currentItem);\necho $formattedProgress; // Output: [50% - 50 / 100][~ 0h 0m 30s remaining]\n```\n\nYou can also customise the format:\n\n```php\n\u003c?php\n\n$customFormat = '[%d%% - %d / %d items][~ %dh %dm %ds left]';\n$formattedProgressCustom = $timeRemaining-\u003egetFormattedProgress($currentItem, $customFormat);\necho $formattedProgressCustom; // Output: [50% - 50 / 100 items][~ 0h 0m 30s left]\n```\n\n### Getting Elapsed Time\n\nTo get the elapsed time since the initialisation:\n\n```php\n\u003c?php\n\n$elapsedTime = $timeRemaining-\u003egetElapsedTime();\necho \"Elapsed time: {$elapsedTime} seconds\\n\";\n```\n\n### Getting Progress\n\nTo get the progress based on the current item:\n\n```php\n\u003c?php\n\n$currentItem = 50;\n$progress = $timeRemaining-\u003egetPercentageProgress($currentItem);\necho \"Progress: {$progress}%\\n\";\n```\n\n### Getting Estimated Total Time\n\nTo get the estimated total time for the process:\n\n```php\n\u003c?php\n\n$estimatedTotalTime = $timeRemaining-\u003egetEstimatedTotalTime($currentItem);\necho \"Estimated total time: {$estimatedTotalTime} seconds\\n\";\n```\n\n### Getting Remaining Time\n\nTo get the remaining time for the process:\n\n```php\n\u003c?php\n\n$remainingTime = $timeRemaining-\u003egetRemainingTime($currentItem);\necho \"Remaining time: {$remainingTime} seconds\\n\";\n```\n\n---\n\n## Development\n\nMost development processes are wrapped up in an easy to use Docker container.\n\n### Enforcing Style\n\nThe projects `.php-cs-fixer.dist.php` config contains the rules that this repo conforms to and will run against the `./src` and `./tests` directory.\n\nFor remote style enforcement there is a GitHub Action configured to automatically run `phpcsfixer`.\n\nFor local style enforcement there is a composer script `composer style` configured to run `phpcsfixer`.\n\n### Testing\n\nFor remote testing there is a GitHub Action setup to automatically run the test suite on the `main` branch or and PR branches.\n\nFor local testing there is a Docker container that is pre-built that contains an Alpine CLI release of PHP + PHPUnit + xdebug. This is setup to test the project and can be setup via the following:\n\n```sh\ncomposer docker-build\n```\n\nThis should trigger Docker Compose to build the image. You can then up the container via the following:\n\n```sh\ncomposer docker-up\n```\n\nThere are tests for all code written, in which can be run via:\n\n```sh\n# PHPUnit with code coverage report\ncomposer test\n\n# PHPUnit with code coverage report, using local phpunit and xdebug\ncomposer test-local\n```\n\nIn those tests, there are Feature tests for a production ready implementation of the package. There are no Unit tests at present.\n\nYou can also easily open a shell in the testing container by using the command:\n\n```sh\ncomposer docker-shell\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fothyn%2Fphp-time-remaining","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fothyn%2Fphp-time-remaining","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fothyn%2Fphp-time-remaining/lists"}