<?php

declare(strict_types=1);

namespace App\View\Components;

use Illuminate\View\Component;

/**
 * Class Badge
 *
 * @package App\View\Components
 */
class Badge extends Component
{
    /**
     * @var string|null
     */
    public ?string $type;

    /**
     * @var string|null
     */
    public ?string $text;

    /**
     * @var string|null
     */
    public ?string $color;

    /**
     * Badge Constructor
     *
     * @param string|null $type
     * @param string|null $text
     * @param string|null $color
     */
    public function __construct(?string $type = null, ?string $text = null, ?string $color = null)
    {
        $this->type = $type ? sprintf('badge-%s', $type) : '';
        $this->color = $color ? sprintf('background-color:%s;', $color) : '';
        $this->text = $text ? mb_strtoupper($text) : '';
    }

    /**
     * @return \Closure|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed|string
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function render()
    {
        return view('components.badge.badge');
    }
}
