<?php

namespace App\Modules\DefinedService\Route\Infrastructure;

use App\Modules\DefinedService\Route\Domain\IdRoute;
use App\Modules\DefinedService\Route\Domain\Route;
use App\Modules\DefinedService\Route\Domain\RouteRepository;
use App\Modules\Shared\Domain\Storage\Criteria\StorageCriteria;
use App\Modules\Shared\Infraestructure\DBRequester;

class MysqlRouteRepository implements RouteRepository
{
    public function find(StorageCriteria $criteria): Route
    {
        return $criteria->run();
    }

    public function search(StorageCriteria $criteria): array
    {
        return $criteria->run();
    }

    public function insert(Route $value): IdRoute
    {
        return new IdRoute(DBRequester::requestInsert($value));
    }

    public function update(Route $value)
    {
        return DBRequester::requestUpdate($value);
    }
}
