<?php

namespace App\Modules\CategoryProvider\Infrastructure;

use App\Modules\CategoryProvider\Domain\CategoryProvider;
use App\Modules\CategoryProvider\Domain\CategoryProviderRepository;
use App\Modules\CategoryProvider\Domain\IdCategoryProvider;
use App\Modules\Shared\Domain\Storage\Criteria\ConcreteStorageCriteria;
use App\Modules\Shared\Infraestructure\DBRequester;
use App\Modules\Shared\Infraestructure\Storage\Criteria\LaravelCriteriaMatcher;

class MysqlCategoryProviderRepository implements CategoryProviderRepository
{
    public function find(ConcreteStorageCriteria $criteria)
    {
        return LaravelCriteriaMatcher::match($criteria);
    }

    public function search(ConcreteStorageCriteria $criteria)
    {
        return LaravelCriteriaMatcher::match($criteria);
    }

    public function insert(CategoryProvider $model)
    {
        return new IdCategoryProvider(DBRequester::requestInsert($model));
    }

    public function updatePartial(CategoryProvider $model)
    {
        return DBRequester::requestUpdatePartial($model);
    }
}
