<?php
declare(strict_types=1);
/*
* Copyright (C) Office National de Publication et de Communication - All Rights Reserved
*
* Unauthorized copying of this file, via any medium is strictly prohibited by law
* This file is proprietary and confidential
*/
namespace App\Elasticsearch;
use App\Entity\Etablissement;
final class Contexte
{
/**
* @var string
*/
public $quoi;
/**
* @var string
*/
public $lieu;
/**
* @var array
*/
public $ids = [];
public function __construct(string $quoi, string $lieu)
{
$this->quoi = $quoi;
$this->lieu = $lieu;
}
public function getBounds(Etablissement $establishment): array
{
$previous = null;
$next = null;
$position = array_search($establishment->getId(), $this->ids, true);
if (null !== $position && \count($this->ids) > 1) {
$previous = $this->ids[$position - 1] ?? null;
$next = $this->ids[$position + 1] ?? reset($this->ids);
}
return [$previous, $next];
}
public function hasEstablishment(Etablissement $establishment): bool
{
return \in_array($establishment->getId(), $this->ids, true);
}
}