import { BaseMatcher } from "../BaseMatcher.js";

/**
 * @template T
 */
export class IsIn extends BaseMatcher {
    /**
     * @type {T[]}
     */
    #collection = []

    /**
     * @param {T[]} collection
     */
    constructor(collection) {
        super();

        this.#collection = collection;
    }

    matches(item, mismatch_description) {
        return this.#collection.includes(item);
    }

    describeTo(description) {
        description.appendText("one of ");
        description.appendValueList("{", ", ", "}", this.#collection);
    }

}
