<?php

namespace App\Modules\ApplicationSession\Infrastructure;

use App\Modules\ApplicationSession\Domain\ApplicationSession;
use App\Modules\ApplicationSession\Domain\ApplicationSessionRepository;
use App\Modules\ApplicationSession\Domain\IdApplicationSession;
use App\Modules\Shared\Domain\Storage\Criteria\ConcreteStorageCriteria;
use App\Modules\Shared\Domain\Storage\Criteria\StorageCriteria;
use App\Modules\Shared\Infraestructure\DBRequester;
use App\Modules\Shared\Infraestructure\Storage\Criteria\LaravelCriteriaMatcher;

class MysqlApplicationSessionRepository implements ApplicationSessionRepository
{
    public function find(StorageCriteria $criteria)
    {
        return $criteria->run();
    }

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

    public function insert(ApplicationSession $model)
    {
        return new IdApplicationSession(DBRequester::requestInsert($model));
    }

}
