{"id":15525163,"url":"https://github.com/antonioribeiro/support","last_synced_at":"2025-04-05T02:10:09.873Z","repository":{"id":13523943,"uuid":"16215177","full_name":"antonioribeiro/support","owner":"antonioribeiro","description":"Support Classes","archived":false,"fork":false,"pushed_at":"2024-05-22T12:52:40.000Z","size":29969,"stargazers_count":58,"open_issues_count":10,"forks_count":51,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T01:09:17.410Z","etag":null,"topics":["helpers","laravel","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonioribeiro.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":"2014-01-24T19:53:57.000Z","updated_at":"2025-02-24T21:31:19.000Z","dependencies_parsed_at":"2024-06-18T12:27:50.318Z","dependency_job_id":null,"html_url":"https://github.com/antonioribeiro/support","commit_stats":{"total_commits":202,"total_committers":15,"mean_commits":"13.466666666666667","dds":0.1089108910891089,"last_synced_commit":"397ba74efb8a46a98766cc0b974818d8e89f9444"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fsupport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fsupport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fsupport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fsupport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonioribeiro","download_url":"https://codeload.github.com/antonioribeiro/support/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["helpers","laravel","php"],"created_at":"2024-10-02T10:55:16.682Z","updated_at":"2025-04-05T02:10:09.853Z","avatar_url":"https://github.com/antonioribeiro.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Support\r\n\r\n## Timer\r\n\r\nA timer class that can be called static or dynamically.\r\n\r\nSource code: [support/blob/master/src/Timer.php](https://github.com/antonioribeiro/support/blob/master/src/Timer.php)\r\n\r\n### Methods\r\n\r\nThose are the methods:\r\n\r\n\tTimer::start();\r\n\tTimer::stop();\r\n\tTimer::isStarted();\r\n\tTimer::isStopped();\r\n\tTimer::elapsed(); // returns a formatted value 9.0192\r\n\tTimer::elapsedRaw(); // returns a double 9.019223049023\r\n\tTimer::setFormat(default = '%.4f');\r\n\r\nYou can name your timers and have more than one running:\r\n\r\n\tTimer::start('mary');\r\n\tTimer::stop('mary');\r\n\tTimer::elapsed('mary');\r\n\r\n### Examples\r\n\r\n\tTimer::start();\r\n\tTimer::start('2nd timer');\r\n\r\n\tvar_dump(\"started: \" . (Timer::isStarted() ? 'yes' : 'no'));\r\n\tvar_dump(\"stopped: \" . (Timer::isStopped() ? 'yes' : 'no'));\r\n\r\n\tsleep(5);\r\n\r\n\tTimer::stop();\r\n\r\n\tvar_dump(\"started: \" . (Timer::isStarted() ? 'yes' : 'no'));\r\n\tvar_dump(\"stopped: \" . (Timer::isStopped() ? 'yes' : 'no'));\r\n\tvar_dump(\"elapsed: \" . Timer::elapsed());\r\n\tvar_dump(\"raw: \" . Timer::elapsedRaw());\r\n\r\n\tsleep(2);\r\n\r\n\tvar_dump(\"'2nd timer' started: \" . (Timer::isStarted('2nd timer') ? 'yes' : 'no'));\r\n\tvar_dump(\"'2nd timer' stopped: \" . (Timer::isStopped('2nd timer') ? 'yes' : 'no'));\r\n\tvar_dump(\"'2nd timer' elapsed: \" . Timer::elapsed('2nd timer'));\r\n\tvar_dump(\"'2nd timer' raw: \" . Timer::elapsedRaw('2nd timer'));\r\n\r\n\tsleep(2);\r\n\r\n\tTimer::stop('2nd timer');\r\n\r\n\tvar_dump(\"'2nd timer' started: \" . (Timer::isStarted('2nd timer') ? 'yes' : 'no'));\r\n\tvar_dump(\"'2nd timer' stopped: \" . (Timer::isStopped('2nd timer') ? 'yes' : 'no'));\r\n\tvar_dump(\"'2nd timer' elapsed: \" . Timer::elapsed('2nd timer'));\r\n\tvar_dump(\"'2nd timer' raw: \" . Timer::elapsedRaw('2nd timer'));\r\n\r\n\tTimer::setFormat('%.8f');\r\n\tvar_dump(\"'2nd timer' elapsed 8 decimals: \" . Timer::elapsed('2nd timer'));\r\n\r\n/// And you can instantiate it and do it all over again:\r\n\r\n\t$t = new Timer;\r\n\t$t-\u003estart();\r\n\tsleep(3);\r\n\t$t-\u003estop();\r\n\tvar_dump(\"elapsed dynamic: \" . $t-\u003eelapsed());\r\n\r\nThis should give you this result:\r\n\r\n\tstring(12) \"started: yes\"\r\n\tstring(11) \"stopped: no\"\r\n\tstring(11) \"started: no\"\r\n\tstring(12) \"stopped: yes\"\r\n\tstring(15) \"elapsed: 5.0004\"\r\n\tstring(20) \"raw: 5.0005040168762\"\r\n\tstring(24) \"'2nd timer' started: yes\"\r\n\tstring(23) \"'2nd timer' stopped: no\"\r\n\tstring(27) \"'2nd timer' elapsed: 7.0008\"\r\n\tstring(32) \"'2nd timer' raw: 7.0008120536804\"\r\n\tstring(23) \"'2nd timer' started: no\"\r\n\tstring(24) \"'2nd timer' stopped: yes\"\r\n\tstring(27) \"'2nd timer' elapsed: 9.0011\"\r\n\tstring(32) \"'2nd timer' raw: 9.0010931491852\"\r\n\tstring(42) \"'2nd timer' elapsed 8 decimals: 9.00113106\"\r\n\tstring(27) \"elapsed dynamic: 3.00018883\"\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonioribeiro%2Fsupport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonioribeiro%2Fsupport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonioribeiro%2Fsupport/lists"}