<?php

declare(strict_types=1);

/*
 * This file is a part of the DiscordPHP project.
 *
 * Copyright (c) 2015-present David Cole <david.cole1340@gmail.com>
 *
 * This file is subject to the MIT license that is bundled
 * with this source code in the LICENSE.md file.
 */

namespace Discord\Voice;

use Discord\Parts\Part;
use Discord\Parts\User\User;

/**
 * Represents a user's flag data sent when a user connects to a voice channel.
 *
 * Undocumented.
 *
 * @since 10.40.0
 *
 * @property      string $user_id The ID of the user.
 * @property-read User   $user    The user.
 * @property      int    $flags   The flags for the user.
 */
class Flags extends Part
{
    /**
     * @inheritDoc
     */
    protected $fillable = [
        'user_id',
        'flags',
    ];

    /**
     * Get the user attribute.
     *
     * @return User The user.
     */
    protected function getUserAttribute(): User
    {
        return $this->discord->users->get('id', $this->attributes['user_id']) ?? $this->factory->part(User::class, ['id' => $this->attributes['user_id']], true);
    }
}
