Remove unnecessary methods from LineRepository
This commit is contained in:
parent
6bd71f0ec5
commit
67f7ba2a88
@ -96,7 +96,10 @@ abstract class DatabaseRepository implements ServiceSubscriberInterface, Reposit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected abstract static function getHandlers();
|
||||
protected static function getHandlers()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
|
@ -17,27 +17,12 @@ use Kadet\Functional as f;
|
||||
|
||||
class GenericLineRepository extends DatabaseRepository implements LineRepository
|
||||
{
|
||||
public function getAll(): Collection
|
||||
{
|
||||
return $this->all();
|
||||
}
|
||||
|
||||
public function getById($id): ?Line
|
||||
{
|
||||
return $this->first(new IdFilter($id));
|
||||
}
|
||||
|
||||
public function getManyById($ids): Collection
|
||||
{
|
||||
return $this->all(new IdFilter($ids));
|
||||
}
|
||||
|
||||
public function first(Modifier ...$modifiers)
|
||||
{
|
||||
return $this->all(Limit::count(1), ...$modifiers)->first();
|
||||
}
|
||||
|
||||
public function all(Modifier ...$modifiers)
|
||||
public function all(Modifier ...$modifiers): Collection
|
||||
{
|
||||
$builder = $this->em
|
||||
->createQueryBuilder()
|
||||
|
@ -3,9 +3,10 @@
|
||||
namespace App\Provider;
|
||||
|
||||
use App\Modifiers\Modifier;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
interface FluentRepository extends Repository
|
||||
{
|
||||
public function first(Modifier ...$modifiers);
|
||||
public function all(Modifier ...$modifiers);
|
||||
public function all(Modifier ...$modifiers): Collection;
|
||||
}
|
||||
|
@ -3,14 +3,6 @@
|
||||
|
||||
namespace App\Provider;
|
||||
|
||||
|
||||
use App\Model\Line;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
interface LineRepository extends FluentRepository
|
||||
{
|
||||
public function getAll(): Collection;
|
||||
|
||||
public function getById($id): ?Line;
|
||||
public function getManyById($ids): Collection;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use App\Model\Departure;
|
||||
use App\Model\Line;
|
||||
use App\Model\Stop;
|
||||
use App\Model\Vehicle;
|
||||
use App\Modifiers\IdFilter;
|
||||
use App\Provider\Database\GenericScheduleRepository;
|
||||
use App\Provider\DepartureRepository;
|
||||
use App\Provider\LineRepository;
|
||||
@ -65,7 +66,8 @@ class ZtmGdanskDepartureRepository implements DepartureRepository
|
||||
$lines = $estimates->map(function ($delay) {
|
||||
return $delay['routeId'];
|
||||
})->unique();
|
||||
$lines = $this->lines->getManyById($lines)->keyBy(t\property('id'));
|
||||
|
||||
$lines = $this->lines->all(new IdFilter($lines))->keyBy(t\property('id'));
|
||||
|
||||
return collect($estimates)->map(function ($delay) use ($stop, $lines) {
|
||||
$scheduled = (new Carbon($delay['theoreticalTime'], 'Europe/Warsaw'))->tz('UTC');
|
||||
|
Loading…
Reference in New Issue
Block a user