{"id":15103774,"url":"https://github.com/techlord001/user-bridge","last_synced_at":"2026-02-03T07:32:47.179Z","repository":{"id":200720411,"uuid":"705253798","full_name":"techlord001/user-bridge","owner":"techlord001","description":"A service for retrieving and creating users via a remote API","archived":false,"fork":false,"pushed_at":"2023-10-17T12:17:59.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T12:30:03.308Z","etag":null,"topics":["api","composer","guzzlehttp","library","php","php-di","php8","phpunit"],"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/techlord001.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,"governance":null}},"created_at":"2023-10-15T13:55:23.000Z","updated_at":"2023-10-15T21:03:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b4f7f94-ae11-4837-a48a-418fb2c91b1c","html_url":"https://github.com/techlord001/user-bridge","commit_stats":null,"previous_names":["techlord001/user-bridge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/techlord001/user-bridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techlord001%2Fuser-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techlord001%2Fuser-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techlord001%2Fuser-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techlord001%2Fuser-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techlord001","download_url":"https://codeload.github.com/techlord001/user-bridge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techlord001%2Fuser-bridge/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263943667,"owners_count":23533628,"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":["api","composer","guzzlehttp","library","php","php-di","php8","phpunit"],"created_at":"2024-09-25T19:42:02.823Z","updated_at":"2026-02-03T07:32:42.159Z","avatar_url":"https://github.com/techlord001.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UserBridge Library\n\nUserBridge is a PHP library that provides a streamlined interface for interacting with user data from [ReqRes](https://reqres.in/). It encapsulates a set of classes and methods to retrieve, create, and serialize user data, offering a simplified and efficient way to interact with the ReqRes API.\n\n## Installation\n\nClone the repository and navigate to the project directory. Install the dependencies using Composer:\n\n```bash\ncomposer install\n```\n\n## Running Tests\n\nExecute the PHPUnit tests to ensure the library's functionality:\n\n```bash\n./vendor/bin/phpunit tests\n```\n\nReplace `tests` with the path to your test files if they are located elsewhere.\n\n## Usage\n\n### Building the Project\n\nThe library is structured around core classes that facilitate interaction with the ReqRes API. The `UserService` class is central, offering methods to retrieve, create, and serialize users.\n\n### Using the `UserService` Class\n\nThe `index.php` file included in the library provides a demonstration of how to use the `UserService` class. You can run it using the following command:\n\n```bash\nphp index.php\n```\n\nThis will execute a series of operations, including retrieving a user by ID, fetching a paginated list of users, creating a new user, and serializing user data.\n\nHere is a basic example of how to use the `UserService` class:\n\n```php\n// Get the UserService from the DI container\n$userService = $container-\u003eget(UserBridge\\Services\\UserService::class);\n\n// Retrieve a user by ID\n$user = $userService-\u003egetUserById(1);\n\n// Retrieve a paginated list of users\n$users = $userService-\u003egetPaginatedUsers(2);\n\n// Create a new user\n$createdUserId = $userService-\u003ecreateUser('John Doe', 'Developer');\n\n// Serialize a user to an array\n$array = $userService-\u003eserialiseUserToArray($user);\n\n// Serialize a user to JSON\n$json = $userService-\u003eserialiseUserToJson($user);\n```\n\n### Available Methods in `UserService`\n\n- `getUserById(int $id): User`: Retrieve a user by their ID.\n- `getPaginatedUsers(int $page = 1): Users`: Fetch a paginated list of users.\n- `createUser(string $name, string $job): int`: Create a new user and return their ID.\n- `serialiseUserToArray(User $user): array`: Serialize a user object to an array.\n- `serialiseUserToJson(User $user): string`: Serialize a user object to a JSON string.\n\n### Explanation of Core Classes\n\n- `UserService`: This is the main service class that provides methods to interact with the user data. It depends on the `ListUsersRetriever`, `SingleUserRetriever`, `UserCreator`, and `UserSerialiser` classes to perform various operations.\n\n- `ListUsersRetriever`: Retrieves a paginated list of users from the ReqRes API.\n\n- `SingleUserRetriever`: Retrieves a single user by their ID from the ReqRes API.\n\n- `UserCreator`: Creates a new user on the ReqRes platform and returns the ID of the newly created user.\n\n- `UserSerialiser`: Converts a User object into an array or JSON format for easy handling and response formatting.\n\n### Connecting to ReqRes API\n\nThis library is configured to connect to the [ReqRes API](https://reqres.in/) by default. It provides a mock API for testing and development purposes, offering a collection of endpoints that simulate real-world API behavior.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechlord001%2Fuser-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechlord001%2Fuser-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechlord001%2Fuser-bridge/lists"}