{"id":22374185,"url":"https://github.com/creativestyle/php-utilities","last_synced_at":"2025-07-30T21:33:08.883Z","repository":{"id":56959099,"uuid":"107573260","full_name":"creativestyle/php-utilities","owner":"creativestyle","description":"A collection of simple but quite handy PHP utility functions for arrays, strings and randomness","archived":false,"fork":false,"pushed_at":"2019-03-22T17:07:11.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-14T15:15:26.614Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/creativestyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-19T16:44:19.000Z","updated_at":"2024-10-24T08:21:42.000Z","dependencies_parsed_at":"2022-08-21T05:10:26.451Z","dependency_job_id":null,"html_url":"https://github.com/creativestyle/php-utilities","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativestyle%2Fphp-utilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativestyle%2Fphp-utilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativestyle%2Fphp-utilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativestyle%2Fphp-utilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creativestyle","download_url":"https://codeload.github.com/creativestyle/php-utilities/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228192318,"owners_count":17882756,"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":[],"created_at":"2024-12-04T21:16:19.934Z","updated_at":"2024-12-04T21:16:20.655Z","avatar_url":"https://github.com/creativestyle.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/creativestyle/php-utilities.svg?branch=master)](https://travis-ci.org/creativestyle/php-utilities)\n\nCommon PHP Utilities Library\n============================\n\nA collection of utility methods for Strings, Arrays and Numbers. A must-have in most projects.\n\n## Installation\n\n```\ncomposer require creativestyle/utilities\n```\n\n## ArrayHelpers\n\n### `pickColumn(array $table, $column)`\n\nAssuming that you've got an array of associate arrays (`$table`) this method\nwill return a single-dimensional array with values of the selected key (`$column`).\n\n### `pick(array $keys, array $subject)`\n\nPicks selected `$keys` from the `$subject` associative array.\n\n### `map(array $arr, $callback)`\n\nMaps the array allowing you to change the keys.\n\nCallback is called with (`$key`, `$value`) parameters and shall return a `[$newkey =\u003e $newvalue]` array.\n\nIt's possible to map a single entry to multiple by returning more than one item from the `$callback`.\n\n### `average(array $arr, $key = null)`\n\nAverages array values.\nIf key is set then the column indicated by key is averaged.\n\n\n## RandHelpers\n\n### `seed()`\n\nReturns long string of digits.\n\n### `randBool($trueChance)`\n\nReturns random bool with `$trueChance` [0, 1] of returning `true`.\n\n### `arrayRand(array $array)`\n\nReturns random array element.\n\n### `sample(array $array, $count = 1)`\n\nReturns `$count` unique random elements from the `$array`.\n\nIf the desired number of results is equal or greater to the array size then the array is shuffled.\nIf it's less or equal to 0, then empty array is returned.\n\n### `gaussianRand($mu, $sigma)`\n\nReturns a random number from gaussian distribution with desired params.\n\n### `normalProbabilityDensity($x, $mu, $sigma)`\n\nReturns a random number from normal distribution with desired params.\n\n\n## StringHelpers\n\n### `urlize($text)`\n\nTransliterates the text keeping only alphanumeric characters and `-`.\nWhitespace is collapsed and transformed to `-`.\n\n### `slugify($text)`\n\nAlias to `urlize()`.\n\n### `joinNotEmpty(array $elements, $delimiter = ', ')`\n\nBehaves the same way as `implode` but skips empty array elements.\n\n### `endsWith($haystack, $needle)`\n\nChecks if `$haystack` ends with `$needle`.\n\n### `startsWith($haystack, $needle)`\n\nChecks if `$haystack` starts with `$needle`.\n\n### `convertToTitleCase($string)`\n\nConverts the string To The Title Case.\n\n### `capitalize($string)`\n\nCapitalizes the string (same as `ucfirst`) in a multibyte-safe manner.\n\n### `humanize($text)`\n\nHumanizes a camelCase variable name. For example `virtualRealityInterposer` will become `Virtual reality interposer`.\n\n### `humanizeConst($constName)`\n\nWorks similar to `humanize` but converts const names like `VIRTUAL_REALITY_INTERPOSER`.\n\n### `isCoercibleToString($value)`\n\nReturns true if the value can be converted to string (is a scalar or has `__toString` method).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreativestyle%2Fphp-utilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreativestyle%2Fphp-utilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreativestyle%2Fphp-utilities/lists"}