<?php

declare(strict_types=1);

/*
 * Chill is a software for social workers
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Chill\MainBundle\Service\Regroupement;

use Chill\MainBundle\Entity\Regroupment;

/**
 * Class RegroupementFiltering.
 *
 * Provides methods to filter and manage groups based on specific criteria.
 */
class RegroupementFiltering
{
    /**
     * Filters the provided groups and returns only those that contain at least one of the specified centers.
     *
     * @param array $groups  an array of groups to filter
     * @param array $centers an array of centers to check against the groups
     *
     * @return array an array of filtered groups containing at least one of the specified centers
     */
    public function filterContainsAtLeastOneCenter(array $groups, array $centers): array
    {
        return array_values(
            array_filter($groups, static fn (Regroupment $group) => $group->containsAtLeastOneCenter($centers)),
        );
    }
}
