2017 © Pedro PelĂĄez
 

library comrade-reader

Comrade, an API reader that takes care about the proper deserialization and hydration

image

wolnosciowiec/comrade-reader

Comrade, an API reader that takes care about the proper deserialization and hydration

  • Friday, January 20, 2017
  • by blackandred
  • Repository
  • 2 Watchers
  • 1 Stars
  • 53 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Comrade Reader

Build Status Code quality rating Code Climate, (*1)

Makes requests to API and allows to decode response to objects, (*2)

Written for Wolnoƛciowiec as a bridge between microservices and comrades who wants to share the anarchist events, articles and news., (*3)

http://wolnosciowiec.net, (*4)

Instalation

composer require wolnosciowiec/comrade-reader
composer dump-autoload -o

Example usage

Given we have an API method "/colors/by-name/{{ colorName }}" on external server that is returning:, (*5)

{
    "success": true,
    "data": {
        "id": 1,
        "color": "Black & Red"
    }
}
<?php

namespace Example;

// Color.php
class Color
{
    protected $id;
    protected $colorName;

    // getter, setter...
}

// ColorRepository.php
class ColorRepository extends AbstractApiRepository
{
    public function getColorByName($colorName)
    {
        return $this->reader->request('GET', '/colors/by-name/' . $this->escape($colorName), '', 3600)
            ->decode(Color::class);
    }
}

// ExampleController.php
class ExampleController extends AbstractController
{
    public function viewAction()
    {
        $color = $this->getRepository()->getColorByName('Red & Black');
        dump($color);
    }
}

The result of our dump() should be an outputted object of Color type to the screen with private properties filled up., (*6)

The Versions

20/01 2017

dev-master

9999999-dev

Comrade, an API reader that takes care about the proper deserialization and hydration

  Sources   Download

LGPLv3

The Requires

 

The Development Requires