{"id":29150559,"url":"https://github.com/roborourke/hooray","last_synced_at":"2025-09-12T22:37:35.394Z","repository":{"id":24518215,"uuid":"27924176","full_name":"roborourke/hooray","owner":"roborourke","description":"PHP array helper for reducing nestiness","archived":false,"fork":false,"pushed_at":"2014-12-12T19:49:36.000Z","size":160,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-11T21:58:43.938Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roborourke.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}},"created_at":"2014-12-12T14:43:20.000Z","updated_at":"2015-01-22T22:01:34.000Z","dependencies_parsed_at":"2022-08-22T22:10:45.745Z","dependency_job_id":null,"html_url":"https://github.com/roborourke/hooray","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/roborourke/hooray","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fhooray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fhooray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fhooray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fhooray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roborourke","download_url":"https://codeload.github.com/roborourke/hooray/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fhooray/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274887441,"owners_count":25368282,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-06-30T23:10:53.122Z","updated_at":"2025-09-12T22:37:35.375Z","avatar_url":"https://github.com/roborourke.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"hooray\n======\n\nPHP array helper for reducing nestiness\n\nThis is a first pass and probably horrible for some reason I haven't thought of. Anyhoo...\n\nYou may or not have done something like this horrendously contrived example when\nworking with arrays in PHP:\n\n```php\n\u003c?php\n\n$a = array( 0, 1, 2, 3, 3, 4, 4, 6, 5 );\n\narray_map( function( $val ) {\n    return $val * 10;\n}, array_unique( array_filter( $a ) ) );\n\nprint_r( $a );\n\n?\u003e\n```\n\nWhat I'm aiming to do with Hooray is make all the normal array functions chainable so\nit's easier to separate them, and also to avoid repeating yourself to some extent.\n\nHere's the equivalent to the above example using Hooray:\n\n```php\n\u003c?php\n\n// constructor takes the array you want to work on\n// if empty you can use push(), fill() etc.. methods\n$a = new hooray( array( 0, 1, 2, 3, 3, 4, 4, 6, 5 ) );\n\n$a\n\t-\u003efilter()\n\t-\u003eunique()\n\t-\u003emap( function( $val ) {\n\t\treturn $val * 10;\n\t} );\n\n// use the get() method to return the modified array\nprint_r( $a-\u003eget() );\n\n?\u003e\n```\n\nMethods that normally return something other than an array will continue to do so eg:\n\n```php\n\u003c?php\n\n$a = new hooray( array( 0, 1, 2, 3, 3, 4, 4, 6, 5 ) );\n\n$a-\u003ecount(); // 9\n\n?\u003e\n```\n\nYou can continue to use the Hooray object after that if you need to do more with the array.\n\n## Other potential goals\n\n* maybe normalise argument order for similar methods - sort of done as you don't have to pass in the array more than once\n* work out if the `__call()` + massive switch statement is really worth it as there's no way to add PHPDoc\n* add additional nice methods like rotate, flatten, deep copy etc..\n* unit tests\n* perf tests\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froborourke%2Fhooray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froborourke%2Fhooray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froborourke%2Fhooray/lists"}