<?php

namespace Planaday\Entities\Course;

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

class CourseCache {
	/** @var Map<int|string, Course> */
	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 ):Course {
		return $this->cache->offsetGet($id);
	}

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

}