<?php
/** 
 * @package     VikRestaurants
 * @subpackage  core
 * @author      E4J s.r.l.
 * @copyright   Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link        https://vikwp.com
 */

namespace E4J\VikRestaurants\Room\Closure\Filters;

// No direct access
defined('ABSPATH') or die('No script kiddies please!');

use E4J\VikRestaurants\Collection\CollectionFilter;
use E4J\VikRestaurants\Collection\Item;

/**
 * Filters the room closures to obtain only the ones that belong to the specified room.
 * 
 * @since 1.10
 */
class RoomFilter implements CollectionFilter
{
    /** @var int */
    protected $roomId;

    /**
     * Class constructor.
     * 
     * @param  int  $roomId  The ID of the room to look for.
     */
    public function __construct(int $roomId)
    {
        $this->roomId = $roomId;
    }

    /**
     * @inheritDoc
     */
    public function match(Item $item)
    {
        return $this->roomId === (int) $item->get('id_room');
    }
}
