{"id":20111915,"url":"https://github.com/graphpql/utils","last_synced_at":"2025-05-06T11:31:29.720Z","repository":{"id":55916713,"uuid":"244390925","full_name":"graphpql/utils","owner":"graphpql","description":":hammer: Common utility classes for infinityloop packages.","archived":false,"fork":false,"pushed_at":"2024-03-16T14:37:22.000Z","size":138,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-02T14:51:50.134Z","etag":null,"topics":["json","php","utility"],"latest_commit_sha":null,"homepage":"https://www.github.com/graphpql","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/graphpql.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}},"created_at":"2020-03-02T14:26:15.000Z","updated_at":"2023-11-04T14:20:39.000Z","dependencies_parsed_at":"2022-08-15T09:20:46.133Z","dependency_job_id":"4eb03d73-44a2-48a8-82dc-b923631b0815","html_url":"https://github.com/graphpql/utils","commit_stats":null,"previous_names":["infinityloop-dev/utils"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Futils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Futils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Futils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphpql%2Futils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphpql","download_url":"https://codeload.github.com/graphpql/utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224499987,"owners_count":17321614,"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":["json","php","utility"],"created_at":"2024-11-13T18:18:10.987Z","updated_at":"2024-11-13T18:18:11.629Z","avatar_url":"https://github.com/graphpql.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Utils [![PHP](https://github.com/graphpql/utils/actions/workflows/php.yml/badge.svg)](https://github.com/graphpql/utils/actions/workflows/php.yml)\n\n:hammer: Common utility classes for infinityloop packages.\n\n## Introduction\n\nThis component provides some utility classes which are used across organisation packages.\n\n## Installation\n\nInstall package using composer\n\n```\ncomposer require infinityloop-dev/utils\n```\n\n## Dependencies\n\n- PHP \u003e= 8.1\n\n## Classes\n\n### Json\n\nJson wrapper which allows you to work with Json as if it was array. Decoding and encoding is fully lazy.\n\n```php\n$json = Json::fromString($jsonString);      // (no decoding is done at this step)\n\n$json['foo'] = 'bar';                       // adding/updating values (decoding is done on this step)\nunset($json['foo2']);                       // removing value\n$json-\u003efoo3 = 'bar3;                        // oop interface is also available\n\n$jsonString = $json-\u003etoString();            // (encoding of updated array into string again)\n$jsonString = $json-\u003etoString();            // (no encoding is done, because previously encoded string is up to date)\n```\n\n### CaseConverter\n\nSimple class which transforms case of strings.\n\n```php\n$string = 'foo-bar_bazFoo123baz';\n\nCaseConverter::toCamelCase($string);        // fooBarBazFoo123Baz\nCaseConverter::toPascalCase($string);       // FooBarBazFoo123Baz\nCaseConverter::toSnakeCase($string);        // foo_bar_baz_foo_123_baz\nCaseConverter::toKebabCase($string);        // foo-bar-baz-foo-123-baz\nCaseConverter::splitWords($string);         // [ foo, bar, baz, foo, 123, baz ]\n```\n\n### ClassSet\n\nTypesafe array of objects of a same type.\n\n```php\nclass Foo { public string $name; public function __construct(string $name) { $this-\u003ename = $name; } }\nclass FooSet extends ObjectSet { protected const INNER_CLASS = Foo::class; }\n\n$set = new FooSet([new Foo(), new Bar(), new Baz()]); // error\n\n// automaticaly generated index keys\n$set = new FooSet([new Foo('foo1'), new Foo('foo2'), new Foo('foo3')]);\necho $set[0]-\u003ename; // foo1\necho $set[1]-\u003ename; // foo2\necho $set[2]-\u003ename; // foo3\n\nclass NamedFooSet extends ObjectSet \n{ \n    protected const INNER_CLASS = Foo::class; \n\n    protected function getKey($fooObject)\n    {\n        return $fooObject-\u003ename;\n    }\n}\n\n// named keys\n$set = new NamedFooSet([new Foo('foo1'), new Foo('foo2'), new Foo('foo3')]);\necho $set['foo1']-\u003ename; // foo1\necho $set['foo2']-\u003ename; // foo2\necho $set['foo3']-\u003ename; // foo3\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphpql%2Futils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphpql%2Futils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphpql%2Futils/lists"}