{"id":20128028,"url":"https://github.com/camelotproject/common","last_synced_at":"2026-04-15T21:31:57.997Z","repository":{"id":62499256,"uuid":"146877046","full_name":"CamelotProject/common","owner":"CamelotProject","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-09T09:23:21.000Z","size":147,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T08:27:06.510Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"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/CamelotProject.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":"2018-08-31T10:23:41.000Z","updated_at":"2022-01-09T09:22:40.000Z","dependencies_parsed_at":"2022-11-02T09:46:38.926Z","dependency_job_id":null,"html_url":"https://github.com/CamelotProject/common","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/CamelotProject%2Fcommon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamelotProject%2Fcommon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamelotProject%2Fcommon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamelotProject%2Fcommon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CamelotProject","download_url":"https://codeload.github.com/CamelotProject/common/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241572216,"owners_count":19984236,"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-11-13T20:25:07.046Z","updated_at":"2026-04-15T21:31:57.952Z","avatar_url":"https://github.com/CamelotProject.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Camelot Common\n==============\n\nThis library provides utility functions to help simplify menial tasks.\n\nThe Camelot team believes the PHP error reporting system is a mistake. Many\nbuilt-in functions utilize it, leading to inconsistent results and head\nscratching.\n\nThis library provides some wrappers around some of these functions. Our code\nshould always throw exceptions instead of triggering errors/warnings/notices\n(excluding deprecation warnings).\n\nTable of Contents:\n- [Assert](#assert)\n- [Deprecated](#deprecated)\n- [Ini](#ini)\n- [Json](#json)\n- [Serialization](#serialization)\n- [Str](#str)\n\n-----\n\n## `Assert`\n\nAdditional assertions built on `Webmozart\\Assert`\n\n\n### `isArrayAccessible`\n\nThrows `InvalidArgumentException` if `$value` is not an array or object\nimplementing `ArrayAccess`.\n\n```php\nisArrayAccessible($value, string $message = ''): void\n```\n\n\n### `isInstanceOfAny`\n\nThrows `InvalidArgumentException` if `$value` is not an instance of one of the\ngiven classes/interfaces.\n\n```php\nisInstanceOfAny($value, string[] $classes, string $message = ''): void\n```\n\n### `isIterable`\n\nThrows `InvalidArgumentException` if `$value` is not an _iterable_. Same as\n`isTraversable()`, just a better name.\n\n```php\nisIterable($value, string $message = ''): void\n```\n\n\n## `Deprecated`\n\nHelper methods for triggering deprecation warnings.\n\n\n### `warn`\n\nShortcut for triggering a deprecation warning for something.\n\n```php\nwarn(string $subject, string|float $since = null, string $suggest = ''): void\n```\n\nExamples:\n\n```php\n// Triggers warning: \"Doing foo is deprecated.\"\nDeprecated::warn('Doing foo');\n\n// Triggers warning: \"Doing foo is deprecated since 3.3 and will be removed in 4.0.\"\nDeprecated::warn('Doing foo', 3.3);\n\n// Triggers warning: \"Doing foo is deprecated since 3.3 and will be removed in 4.0. Do bar instead.\"\nDeprecated::warn('Doing foo', 3.3, 'Do bar instead');\n```\n\n\n### `method`\n\nShortcut for triggering a deprecation warning for a method.\n\n```php\nmethod(string|float $since = null, string $suggest = '', string $method = null): void\n```\n\n`$suggest` can be a sentence describing what to use instead. Or it can be a\nmethod name or `class::method` which will be converted to a sentence.\n\n`$method` defaults to the method/function it was called from.\n  - If called from constructor, warning message says the class is deprecated.\n  - If called from magic method, warning message says the method/property\n    called with is deprecated.\n\nExample:\n\n```php\nclass Foo\n{\n    public function world()\n    {\n        // Triggers warning: \"Foo::world() is deprecated since 3.3 and will be removed in 4.0. Use hello() instead.\"\n        Deprecated::method(3.3, 'hello');\n    }\n}\n```\n\n\n### `cls`\n\nShortcut for triggering a deprecation warning for a class.\n\n```php\ncls(string $class, string|float $since = null, string $suggest = null): void\n```\n\n`$suggest` can be a sentence describing what to use instead. Or it can be a\nclass name which will be converted to a sentence.\n\nExamples:\n\n```php\n// Triggers warning: \"Foo\\Bar is deprecated.\"\nDeprecated::cls('Foo\\Bar');\n\n// Triggers warning: \"Foo\\Bar is deprecated. Use Bar\\Baz instead.\"\nDeprecated::cls('Foo\\Bar', null, 'Bar\\Baz');\n```\n\n\n## `Ini`\n\nHandles setting and retrieving values from PHP's configuration.\n\n\n### `has`\n\nChecks whether the key exists.\n\n```php\nhas(string $key): bool\n```\n\n\n### `getStr`\n\nGet a string value. The default is returned if the key does not exist or the\nvalue is empty.\n\n```php\ngetStr(string $key, string $default = null): ?string\n```\n\n\n### `getBool`\n\nGet a boolean value. False is returned if the key does not exist or the value\nis empty.\n\n```php\ngetBool(string $key): bool\n```\n\n\n### `getNumeric`\n\nGet a numeric value. The default is returned if the key does not exist or the\nvalue is empty.\n\n```php\ngetNumeric(string $key, int|float $default = null): int|float|null\n```\n\n\n### `getBytes`\n\nGet a memory size value, such as `memory_limit`, and convert it to an integer.\nThe default is returned if the key does not exist or the value is empty.\n\n```php\ngetBytes(string $key, int $default = null): ?int\n```\n\n\n### `set`\n\nSet a new value for the given key.\nThrows `RuntimeException` if the key does not exist, it is not editable, or\nsomething goes wrong.\n\n```php\nset(string $key, ?scalar $value): void\n```\n\n\n## `Json`\n\nHandles JSON parsing/dumping with error handling.\n\n\n### `parse`\n\nParses JSON _string_ to _array_ or _scalar_.\nThrows `ParseException` if anything goes wrong.\n\n```php\nparse(string $json, int $options = 0, int $depth = 512): string\n```\n\nWe use [`seld/jsonlint`](https://github.com/Seldaek/jsonlint) to determine why\nthe parsing failed and include it in the exception message.\n\n\n### `dump`\n\nDumps _mixed_ to JSON _string_. Throws `DumpException` if anything goes wrong.\n\n```php\ndump(mixed $data, int $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE, int $depth = 512): string\n```\n\nIf input contains invalid UTF-8 characters we try to convert these for you\nbefore failing.\n\n\n### `test`\n\nReturns whether the string is valid JSON.\n\n```php\ntest(string $json): bool\n```\n\n\n## `Serialization`\n\nHandles PHP serialization parsing/dumping with error handling.\n\n\n### `parse`\n\nParses PHP serialized _string_.\n\nThrows `ParseException` if a serialized class cannot be found or anything else\ngoes wrong.\n\n```php\nparse(string $value, array $options = []): mixed\n```\n\nNote: `$options` parameter is ignored on PHP 5.\n\nSee [`unserialize()`](http://php.net/manual/en/function.unserialize.php) for\ndetails.\n\n\n### `dump`\n\nDumps anything to a PHP serialized _string_.\n\nThrows `DumpException` if the input is not serializable or anything else goes\nwrong.\n\n```php\ndump(mixed $value): string\n```\n\n\n## `Str`\n\nCommon string methods.\n\n\n### `replaceFirst`\n\nReplaces the first occurrence of the $search text on the $subject.\n\n```php\nreplaceFirst(string $subject, string $search, string $replace, bool $caseSensitive = true): string\n```\n\n\n### `replaceLast`\n\nReplaces the last occurrence of the $search text on the $subject.\n\n```php\nreplaceLast(string $subject, string $search, string $replace, bool $caseSensitive = true): string\n```\n\n\n### `removeFirst`\n\nRemoves the first occurrence of the $search text on the $subject.\n\n```php\nremoveFirst(string $subject, string $search, bool $caseSensitive = true): string\n```\n\n\n### `removeLast`\n\nRemoves the last occurrence of the $search text on the $subject.\n\n```php\nremoveLast(string $subject, string $search, bool $caseSensitive = true): string\n```\n\n\n### `splitFirst`\n\nSplits a $subject on the $delimiter and returns the first part.\n\n```php\nsplitFirst(string $subject, string $delimiter): string\n```\n\n\n### `splitLast`\n\nSplits a $subject on the $delimiter and returns the last part.\n\n```php\nsplitLast(string $subject, string $delimiter): string\n```\n\n### `endsWith`\n\nReturns whether the subjects ends with the search string.\n\n```php\nendsWith(string $subject, string $search, bool $caseSensitive = true): bool\n```\n\n\n### `className`\n\nReturns the class name without the namespace, of a string FQCN, or object.\n\n```php\nclassName(string|object $class): string\n```\n\n\n### `humanize`\n\nConverts a string from camel case and snake case to a human readable string.\n\n```php\nhumanize(string $text): string\n```\n\n\n### `camelCase`\n\nConverts a string from snake case to camel case.\n\n```php\ncamelCase(string $text, bool $lowercaseFirstChar = false): string\n```\n\n\n### `snakeCase`\n\nConverts a string from camel case to snake case.\n\n```php\nsnakeCase(string $text): string\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamelotproject%2Fcommon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcamelotproject%2Fcommon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamelotproject%2Fcommon/lists"}