<?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\Action\User\UpdateProfile;

use Chill\MainBundle\Entity\User;

final readonly class UpdateProfileCommandHandler
{
    public function updateProfile(User $user, UpdateProfileCommand $command): void
    {
        $user->setPhonenumber($command->phonenumber);
        $user->setLocale($command->locale);

        foreach ($command->notificationFlags as $flag => $values) {
            $user->setNotificationImmediately($flag, $values['immediate_email']);
            $user->setNotificationDailyDigest($flag, $values['daily_digest']);
        }
    }
}
