PHPackages                             clearcode/eh-library - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. clearcode/eh-library

ActiveLibrary

clearcode/eh-library
====================

Model and use cases for rest api course

120PHP

Since Dec 3Pushed 10y ago10 watchersCompare

[ Source](https://github.com/ClearcodeHQ/eh-library)[ Packagist](https://packagist.org/packages/clearcode/eh-library)[ RSS](/packages/clearcode-eh-library/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/465988b627b98d1a0f0820598af763843870f84855e6cb0f13aa59ebdb0b2b74/68747470733a2f2f7472617669732d63692e6f72672f436c656172636f646548512f65682d6c6962726172792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ClearcodeHQ/eh-library)[![Coverage Status](https://camo.githubusercontent.com/b4a2431542eda3eb4ca6ba138cedef9061da2f1ded90dd45fc402d26cabab904/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f436c656172636f646548512f65682d6c6962726172792f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/ClearcodeHQ/eh-library?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/35cb88356129a1b00bcf3928a63121b4c3d2d510d15c7479faa69acd581c1f69/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f436c656172636f646548512f65682d6c6962726172792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ClearcodeHQ/eh-library/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/9bc3bbd79738dcc552bf6aa0b9067da987625ed6af8825ea94da4c573731fc58/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3536356331366336343035326538303033623030303030652f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/565c16c64052e8003b00000e)

EH-library Application for rest api course
==========================================

[](#eh-library-application-for-rest-api-course)

This repository is a simple model which could be used to build REST API.

Requirements
------------

[](#requirements)

```
    "require": {
        "php": ">=5.5",
        "ramsey/uuid": "~3.0",
        "everzet/persisted-objects": "~1.0"
    },
```

Installation
------------

[](#installation)

```
composer require --dev clearcode/eh-library

```

Features
--------

[](#features)

- Add book to library,
- View books in library,
- Reserving a book,
- Give away a book,
- Give back a book,
- View reservations.

Description
-----------

[](#description)

Api of library.

```
//...

interface Library
{
    /**
     * @param UuidInterface $bookId
     * @param string        $title
     * @param string        $authors
     * @param string        $isbn
     */
    public function addBook(UuidInterface $bookId, $title, $authors, $isbn);

    /**
     * @param int  $page
     * @param null $booksPerPage
     *
     * @return BookView[]
     */
    public function listOfBooks($page = 1, $booksPerPage = null);

    /**
     * @param UuidInterface $reservationId
     * @param UuidInterface $bookId
     * @param string        $email
     */
    public function createReservation(UuidInterface $reservationId, UuidInterface $bookId, $email);

    /**
     * @param UuidInterface $reservationId
     * @param \DateTime     $givenAwayAt
     *
     * @throws BookInReservationAlreadyGivenAway
     */
    public function giveAwayBookInReservation(UuidInterface $reservationId, \DateTime $givenAwayAt);

    /**
     * @param UuidInterface $reservationId
     *
     * @throws CannotGiveBackReservationWhichWasNotGivenAway
     */
    public function giveBackBookFromReservation(UuidInterface $reservationId);

    /**
     * @param UuidInterface $bookId
     *
     * @return ReservationView[]
     */
    public function listReservationsForBook(UuidInterface $bookId);
}
```

This interface is implement by `Clearcode\EHLibrary\Application` class.

Example
-------

[](#example)

Example of adding book to library.

```
//..
namespace Clearcode;

use Clearcode\EHLibrary\Application;
use Ramsey\Uuid\Uuid;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class Controller
{
    public function addBookToLibraryAction(Request $request)
    {
        $bookId = Uuid::fromString($request->request->get('bookId'));

        //Library implementation
        $app = new Application();
        $app->addBook($bookId, $request->request->get('title'), $request->request->get('authors'), $request->request->get('isbn'));

        return new Response(json_encode(['id' => (string) $bookId]), 201);
    }
}
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

---

Top Contributors

[![lzakrzewski](https://avatars.githubusercontent.com/u/4248462?v=4)](https://github.com/lzakrzewski "lzakrzewski (71 commits)")[![pawaclawczyk](https://avatars.githubusercontent.com/u/1135845?v=4)](https://github.com/pawaclawczyk "pawaclawczyk (15 commits)")

### Embed Badge

![Health badge](/badges/clearcode-eh-library/health.svg)

```
[![Health](https://phpackages.com/badges/clearcode-eh-library/health.svg)](https://phpackages.com/packages/clearcode-eh-library)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
