{"id":28955810,"url":"https://github.com/kodedphp/stdlib","last_synced_at":"2025-07-15T19:33:27.959Z","repository":{"id":52248475,"uuid":"83201936","full_name":"kodedphp/stdlib","owner":"kodedphp","description":"A shareable library for utility classes and functions.","archived":false,"fork":false,"pushed_at":"2025-06-23T13:01:14.000Z","size":269,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-23T13:50:18.292Z","etag":null,"topics":["dto","exceptions","immutable","mime","ulid","ulid-generator","utility","uuid","uuid-generator"],"latest_commit_sha":null,"homepage":"","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/kodedphp.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,"zenodo":null}},"created_at":"2017-02-26T10:56:44.000Z","updated_at":"2025-06-23T12:57:22.000Z","dependencies_parsed_at":"2025-06-25T11:15:26.901Z","dependency_job_id":null,"html_url":"https://github.com/kodedphp/stdlib","commit_stats":{"total_commits":291,"total_committers":3,"mean_commits":97.0,"dds":0.05154639175257736,"last_synced_commit":"8dfc1c18ed772e36e3c287ec08f565e03abd95f9"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/kodedphp/stdlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fstdlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fstdlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fstdlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fstdlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kodedphp","download_url":"https://codeload.github.com/kodedphp/stdlib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodedphp%2Fstdlib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265454973,"owners_count":23768462,"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":["dto","exceptions","immutable","mime","ulid","ulid-generator","utility","uuid","uuid-generator"],"created_at":"2025-06-23T20:10:09.392Z","updated_at":"2025-07-15T19:33:27.913Z","avatar_url":"https://github.com/kodedphp.png","language":"PHP","readme":"Koded Standard Library\n======================\n\nA standard library for shareable classes and functions.\n\n[![CI](https://github.com/kodedphp/stdlib/actions/workflows/ci.yml/badge.svg)](https://github.com/kodedphp/stdlib/actions/workflows/ci.yml)\n[![Latest Stable Version](https://img.shields.io/packagist/v/koded/stdlib.svg)](https://packagist.org/packages/koded/stdlib)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/koded/stdlib.svg)](https://packagist.org/packages/koded/stdlib)\n[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg)](https://php.net/)\n\n\nClasses\n-------\n\n### `Immutable`\n- `get(string $index, $default = null)`\n- `has($index): bool`\n- `equals(string $propertyA, string $propertyB): bool`\n- `find(string $index, $default = null)`\n- `extract(array $keys): array`\n- `filter(iterable $data,\n          string $prefix,\n          bool $lowercase = true,\n          bool $trim = true): array`\n- `namespace(string $prefix, bool $lowercase = true, bool $trim = true)`\n- `count()`\n- `toArray(): array`\n- `toJSON(int $options = 0): string`\n- `toXML(string $root): string`\n- `toArguments(): Arguments`\n\n### `Arguments`\n(implements `Immutable` methods)\n- `set(string $index, $value)`\n- `import(array $values)`\n- `upsert(string $index, $value)`\n- `bind(string $index, \u0026$variable)`\n- `pull(string $index, $default = null)`\n- `delete(string $index)`\n- `clear()`\n- `toImmutable(): Immutable`\n\n\n### `ExtendedArguments`\n``ExtendedArguments extends Arguments``\n\n- `flatten(): ExtendedArguments`\n\nSupports _dot-notation_ for index names. Example:\n```php\n$args = new \\Koded\\Stdlib\\ExtendedArguments([\n    'foo' =\u003e [\n        'bar' =\u003e [\n            'baz' =\u003e 42\n        ]\n    ]\n]);\n\n$args-\u003eget('foo.bar');\n// returns ['baz' =\u003e 42]\n\n$args-\u003eget('foo.bar.baz');\n// returns 42\n\n$args-\u003eflatten();\n// returns ['foo.bar.baz' =\u003e 42]\n\n$args-\u003eset('foo.bar', 'baz');\n// ['foo' =\u003e ['bar' =\u003e 'baz']]\n```\n\n### `Config`\nClass `Config` works as a parameter bag that provides ways to fill it\nfrom files or other `Config` instances. There are 2 common patterns\nto populate the config,\n\neither you can fill the Config instance from config files:\n```php\n$app-\u003econfig()-\u003efromPhpFile('myconfig.php');\n$app-\u003econfig()-\u003efromJsonFile('myconfig.json');\n$app-\u003econfig()-\u003efromEnvFile('.env');\n$app-\u003econfig()-\u003efromIniFile('myconfig.ini');\n```\nor alternatively you can define the configuration options in the instance\nthat calls `fromObject`,\n```php\n$app-\u003econfig()-\u003efromObject(MyConfig::class);\n$app-\u003econfig()-\u003efromObject($myconfig); // $myconfig is instance of Config\n```\nOther interesting way to load configuration is from an environment variable\nthat points to a file\n```php\n$app-\u003econfig()-\u003efromEnvVariable('MY_APP_SETTINGS');\n```\nIn this case, before launching the application you have to set the env variable\nto the file you want to use. On Linux and OSX use the export statement\n```shell script\nexport MY_APP_SETTINGS='/path/to/config/file.php'\n```\nor somewhere in your app bootstrap phase before constructing the Api instance\n```php\nputenv('MY_APP_SETTINGS=/path/to/config/file.php');\n```\n\n- `fromEnvironment(\n           array $variableNames,\n           string $namespace = '',\n           bool $lowercase = true,\n           bool $trim = true\n       ): Configuration`\n- `fromJsonFile(string $file): Configuration`\n- `fromPhpFile(string $file): Configuration`\n- `fromEnvVariable(string $variable): Configuration`\n- `fromIniFile(string $file): Configuration`\n- `fromObject($object): Configuration`\n- `withParameters(array $parameters): Configuration`\n- `silent(bool $silent): Configuration`\n- `build(string $context): Configuration`\n\n\n### `Mime`\n- `type(string $extension, int $index = 0): string`\n- `types(string $extension): array`\n- `supports(string $type): bool`\n- `extensions(string $type): array`\n\n\n### `UUID`\nClass UUID generates `Universally Unique Identifiers` following the [RFC 4122][rfc-4122].\n\n- `v1(string|null $address = null): string`\n- `v3(string $namespace, $name): string`\n- `v4(): string`\n- `v5(string $namespace, string $name): string`\n- `valid(string $uuid): bool`\n- `matches(string $uuid, int $version = 4): bool`\n- `toBase64(string $uuid): string`\n- `fromBase64(string $base64): string`\n\n### `ULID`\nClass ULID generates `Universally Unique Lexicographically Sortable Identifiers`\n\n- `generate(int $count = 1): self`\n- `fromULID(string $ulid): self`\n- `fromUUID(string $ulid): self`\n- `fromTimestamp(float $timestamp): self`\n- `fromDateTime(string $datetime): self`\n- `toULID(): array|string`\n- `toUUID(): array|string`\n- `toDateTime(): array|DateTime`\n- `count(): int`\n- `valid(string $uuid): bool`\n\nFunctions\n---------\n```php\nfunction arguments(...$values): Argument;\nfunction extended(...$values): ExtendedArguments;\nfunction value(...$values): Data;\nfunction tap(mixed $value, callable|null $callable = null): mixed;\nfunction camel_to_snake_case(string $string): string;\nfunction env(string|null $name = null, mixed $default = null, array|null $initialState = null): mixed;\nfunction error_log(string $function, string $message, $data): void;\nfunction htmlencode(string $input, string $encoding = 'UTF-8'): string;\nfunction is_associative(array $array): bool;\nfunction json_serialize($value, int $options = JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_SLASHES): string;\nfunction json_unserialize(string $json, bool $associative = false);\nfunction now(): DateTimeImmutable;\nfunction randomstring(int $length = 16, string $prefix = '', string $suffix = ''): string;\nfunction rmdir(string $dirname): bool;\nfunction snake_to_camel_case(string $string): string;\nfunction to_delimited_string(string $string, int $delimiter): string;\nfunction to_kebab_string(string $string): string;\nfunction xml_serialize(string $root, iterable $data): string;\nfunction xml_unserialize(string $xml): array;\n```\n\nCode quality\n------------\n\n[![Code Coverage](https://scrutinizer-ci.com/g/kodedphp/stdlib/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/stdlib/?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/kodedphp/stdlib/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/kodedphp/stdlib/?branch=master)\n\n```shell script\nvendor/bin/phpbench run --report=default\nvendor/bin/phpunit\n```\n\nLicense\n-------\n\n[![Software license](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](LICENSE)\n\nThe code is distributed under the terms of [The 3-Clause BSD license](LICENSE).\n\n\n[rfc-4122]: http://tools.ietf.org/html/rfc4122\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodedphp%2Fstdlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkodedphp%2Fstdlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodedphp%2Fstdlib/lists"}