<?php

namespace Planaday\Entities\DayPart;

use ArrayAccess;
use Countable;
use Planaday\Entities\DayPart\DTO\DayPart;
use Planaday\Utility\DataGrouping\Map;
use Traversable;

class DayPartCache {
	/** @var Map<int|string, DayPart> */
	protected Map $cache;

	public function __construct() {
		$this->cache = new Map();
	}

	public function contains( int $id ):bool {
		return $this->cache->offsetExists($id);
	}

	public function get( int $id ):DayPart {
		return $this->cache->offsetGet($id);
	}

	public function set( DayPart $dayPart):void {
		$this->cache->offsetSet($dayPart->getId(), $dayPart);
	}

}