{"id":22894275,"url":"https://github.com/clearcodehq/eh-library","last_synced_at":"2025-03-31T22:38:36.867Z","repository":{"id":56953634,"uuid":"46922122","full_name":"ClearcodeHQ/eh-library","owner":"ClearcodeHQ","description":null,"archived":false,"fork":false,"pushed_at":"2015-12-03T22:21:33.000Z","size":95,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-30T13:37:08.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ClearcodeHQ.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":"2015-11-26T11:14:03.000Z","updated_at":"2016-07-03T23:19:27.000Z","dependencies_parsed_at":"2022-08-21T08:20:39.902Z","dependency_job_id":null,"html_url":"https://github.com/ClearcodeHQ/eh-library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClearcodeHQ%2Feh-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClearcodeHQ%2Feh-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClearcodeHQ%2Feh-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClearcodeHQ%2Feh-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ClearcodeHQ","download_url":"https://codeload.github.com/ClearcodeHQ/eh-library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246552972,"owners_count":20795835,"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-13T23:17:22.448Z","updated_at":"2025-03-31T22:38:36.847Z","avatar_url":"https://github.com/ClearcodeHQ.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/ClearcodeHQ/eh-library.svg?branch=master)](https://travis-ci.org/ClearcodeHQ/eh-library)\n[![Coverage Status](https://coveralls.io/repos/ClearcodeHQ/eh-library/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/ClearcodeHQ/eh-library?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ClearcodeHQ/eh-library/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ClearcodeHQ/eh-library/?branch=master)\n[![Dependency Status](https://www.versioneye.com/user/projects/565c16c64052e8003b00000e/badge.svg?style=flat)](https://www.versioneye.com/user/projects/565c16c64052e8003b00000e)\n\n# EH-library Application for rest api course\n\nThis repository is a simple model which could be used to build REST API.\n\n## Requirements\n```json\n    \"require\": {\n        \"php\": \"\u003e=5.5\",\n        \"ramsey/uuid\": \"~3.0\",\n        \"everzet/persisted-objects\": \"~1.0\"\n    },\n```\n\n## Installation\n```\ncomposer require --dev clearcode/eh-library\n```\n\n## Features\n- Add book to library,\n- View books in library,\n- Reserving a book,\n- Give away a book,\n- Give back a book,\n- View reservations.\n\n## Description\n\nApi of library.\n\n```php\n//...\n\ninterface Library\n{\n    /**\n     * @param UuidInterface $bookId\n     * @param string        $title\n     * @param string        $authors\n     * @param string        $isbn\n     */\n    public function addBook(UuidInterface $bookId, $title, $authors, $isbn);\n\n    /**\n     * @param int  $page\n     * @param null $booksPerPage\n     *\n     * @return BookView[]\n     */\n    public function listOfBooks($page = 1, $booksPerPage = null);\n\n    /**\n     * @param UuidInterface $reservationId\n     * @param UuidInterface $bookId\n     * @param string        $email\n     */\n    public function createReservation(UuidInterface $reservationId, UuidInterface $bookId, $email);\n\n    /**\n     * @param UuidInterface $reservationId\n     * @param \\DateTime     $givenAwayAt\n     *\n     * @throws BookInReservationAlreadyGivenAway\n     */\n    public function giveAwayBookInReservation(UuidInterface $reservationId, \\DateTime $givenAwayAt);\n\n    /**\n     * @param UuidInterface $reservationId\n     * \n     * @throws CannotGiveBackReservationWhichWasNotGivenAway\n     */\n    public function giveBackBookFromReservation(UuidInterface $reservationId);\n\n    /**\n     * @param UuidInterface $bookId\n     *\n     * @return ReservationView[]\n     */\n    public function listReservationsForBook(UuidInterface $bookId);\n}\n```\n\nThis interface is implement by `Clearcode\\EHLibrary\\Application` class.\n\n## Example\n\nExample of adding book to library.\n\n```php\n//..\nnamespace Clearcode;\n\nuse Clearcode\\EHLibrary\\Application;\nuse Ramsey\\Uuid\\Uuid;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nclass Controller\n{\n    public function addBookToLibraryAction(Request $request)\n    {\n        $bookId = Uuid::fromString($request-\u003erequest-\u003eget('bookId'));\n        \n        //Library implementation\n        $app = new Application();\n        $app-\u003eaddBook($bookId, $request-\u003erequest-\u003eget('title'), $request-\u003erequest-\u003eget('authors'), $request-\u003erequest-\u003eget('isbn'));\n        \n        return new Response(json_encode(['id' =\u003e (string) $bookId]), 201);\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearcodehq%2Feh-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclearcodehq%2Feh-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearcodehq%2Feh-library/lists"}