{"id":22835433,"url":"https://github.com/dxw/php-missing","last_synced_at":"2025-04-24T00:09:03.566Z","repository":{"id":10872724,"uuid":"13160019","full_name":"dxw/php-missing","owner":"dxw","description":"Some functions missing from PHP's stdlib","archived":false,"fork":false,"pushed_at":"2023-07-19T13:38:43.000Z","size":101,"stargazers_count":5,"open_issues_count":7,"forks_count":2,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-24T00:08:57.175Z","etag":null,"topics":["composer","govpress","packagist","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/dxw/php-missing","language":"PHP","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/dxw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING.md","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":"2013-09-27T20:06:59.000Z","updated_at":"2024-07-18T18:12:43.000Z","dependencies_parsed_at":"2024-12-12T22:09:56.102Z","dependency_job_id":"df2a35f2-cb0b-4dcc-bfdc-dd08b60d2af2","html_url":"https://github.com/dxw/php-missing","commit_stats":{"total_commits":70,"total_committers":6,"mean_commits":"11.666666666666666","dds":"0.30000000000000004","last_synced_commit":"172d0a2386645192f1824cdc23f88a66d2fe04cb"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxw%2Fphp-missing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxw%2Fphp-missing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxw%2Fphp-missing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxw%2Fphp-missing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dxw","download_url":"https://codeload.github.com/dxw/php-missing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535099,"owners_count":21446508,"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":["composer","govpress","packagist","php"],"created_at":"2024-12-12T22:09:53.199Z","updated_at":"2025-04-24T00:09:03.540Z","avatar_url":"https://github.com/dxw.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-missing\n\nPHP's standard library contains a lot of stuff, but it's missing a lot of stuff. All these functions are basic things that I've had to implement over and over again.\n\n## Installation\n\nInstall [composer](http://getcomposer.org/).\n\nRun the following in the root of your project:\n\n    composer require dxw/php-missing\n\nOr, create a composer.json file with the following contents and run \"composer install\":\n\n    {\n      \"require\": {\n        \"dxw/php-missing\": \"^2.0\"\n      }\n    }\n\n## API\n\n* [\\Missing\\Arrays::flatten](#arr_flatten)\n* [\\Missing\\Arrays::sortBy](#arr_sort_by)\n* [\\Missing\\Dates::parse](#date_parse)\n* [\\Missing\\Dates::strftime](#date_strftime)\n* [\\Missing\\Ints::ordinalize](#int_ordinalize)\n* [\\Missing\\Reflection::call](#reflection_call)\n* [\\Missing\\Strings::startsWith](#string_starts_with)\n* [\\Missing\\Strings::endsWith](#string_ends_with)\n* [\\Missing\\Strings::getOutput](#string_get_output)\n\n### Arrays\n\n\u003ca name=\"arr_flatten\"\u003e\u003c/a\u003e\n#### $array = \\Missing\\Arrays::flatten($array)\n\nFlattens an array containing arrays.\n\n    \\Missing\\Arrays::flatten([1, [2, 3, [4, 5]]]) === [1, 2, 3, 4, 5]\n\n\u003ca name=\"arr_sort_by\"\u003e\u003c/a\u003e\n#### $array = \\Missing\\Arrays::sortBy($array, $callback)\n\nSorts $array by $callback($array_element).\n\n    \\Missing\\Arrays::sortBy(['abc', 'ab', 'a'], function ($a) {return strlen($a);}) === ['a', 'ab', 'abc']\n\n### Dates\n\n\u003ca name=\"date_parse\"\u003e\u003c/a\u003e\n#### list($timestamp, $err) = \\Missing\\Dates::parse($str)\n\nParses several common/standard time formats, returns a `Dxw\\Result\\Result` object containing either the UNIX timestamp or an error.\n\n    $result = \\Missing\\Dates::parse(get_post_meta($post-\u003eID, '_EventStartDate', true));\n    if ($result-\u003eisErr()) {\n      $date = 'Unknown date';\n    } else {\n      $date = strftime('%e %B %Y', $result-\u003eunwrap());\n    }\n\nThe following date formats are parsed:\n\n* %Y-%m-%dT%H:%M:%S\n* %Y-%m-%d %H:%M:%S\n* %Y-%m-%dT%H:%M\n* %Y-%m-%d %H:%M\n* %Y-%m-%d\n\n\u003ca name=\"date_strftime\"\u003e\u003c/a\u003e\n#### $date = \\Missing\\Dates::strftime($date_string, $format, $else, $tz)\n\nParses $date_string using \\Missing\\Dates::parse() (also accepts a UTC timestamp), if it parses correctly, return the date formatted with $format in the timezone $tz, otherwise return $else.\n\n    \u003cp\u003eDate: \u003c?php echo \\Missing\\Dates::strftime($date, 'd/m/Y', 'unknown', 'Europe/London') ?\u003e\u003c/p\u003e\n\n### Ints\n\n\u003ca name=\"int_ordinalize\"\u003e\u003c/a\u003e\n#### $string = \\Missing\\Ints::ordinalize($number)\n\nReturns English ordinals for any given integer (i.e. 1 =\u003e \"1st\", 2 =\u003e \"2nd\").\n\nCopied directly from active_record's [Inflector#ordinalize](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-ordinalize) (also MIT licensed).\n\n### Reflection\n\n\u003ca name=\"reflection_call\"\u003e\u003c/a\u003e\n#### $value = \\Missing\\Reflection::call($object, $methodName, $arguments)\n\nCalls private or protected method $methodName of $object with $arguments (an array) and returns what it returns.\n\n### Strings\n\n\u003ca name=\"string_starts_with\"\u003e\u003c/a\u003e\n#### $bool = \\Missing\\Strings::startsWith($haystack, $needle)\n\nReturns true if string $haystack starts with $needle (uses substr() - regexes not supported).\n\n\u003ca name=\"string_ends_with\"\u003e\u003c/a\u003e\n#### $bool = \\Missing\\Strings::endsWith($haystack, $needle)\n\nReturns true if string $haystack ends with $needle (uses substr() - regexes not supported).\n\n\u003ca name=\"string_get_output\"\u003e\u003c/a\u003e\n#### $string = \\Missing\\Strings::getOutput($callback)\n\nExecutes $callback, returns what it prints as a string.\n\n\n## Licence\n\nMIT - see COPYING.md\n\n\\Missing\\Ints::ordinal and \\Missing\\Ints::ordinalize were ported from the Rails active_support module, also licensed under MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxw%2Fphp-missing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdxw%2Fphp-missing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxw%2Fphp-missing/lists"}