00f100/fcphp-repository

There is no license information available for the latest version (0.1.0) of this package.

Package to manipulate repositories

0.1.0 2018-08-29 01:20 UTC

This package is auto-updated.

Last update: 2024-11-18 05:47:32 UTC


README

Abstract class to Repository FcPhp

Build Status codecov

PHP Version Packagist Version Total Downloads

How to install

Composer:

$ composer require 00f100/fcphp-repository

or add in composer.json

{
    "require": {
        "00f100/fcphp-repository": "*"
    }
}

How to use

namespace Path\To
{
    use FcPhp\Repository\Repository;

    class ExampleRepository extends Repository
    {

    }
}
Configure dependencies
use Exception;
use FcPhp\Di\Facades\DiFacade;
use FcPhp\Datasource\Factories\Factory;
use FcPhp\Cache\Facades\CacheFacade;
use FcPhp\Datasource\Interfaces\IQuery;

$di = DiFacade::getInstance();
$factory = new Factory($di);
$cache = CacheFacade::getInstance('path/to/cache');
Create instance and define error callback
use Path\To\ExampleRepository;

// See: github.com/00f100/fcphp-datasource
$datasource = new Datasource();

$callbackError = function(IQuery $query, Exception $e) {
    $this->assertInstanceOf(IQuery::class, $query);
    $this->assertInstanceOf(Exception::class, $e);
};

$instance = new ExampleRepository($datasource, $cache, $factory, $callbackError);

// Query
$query = $instance->getQuery();