File "Endpoint.php"

Full Path: /var/www/html/back/vendor/knuckleswtf/scribe/src/Attributes/Endpoint.php
File size: 747 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace Knuckles\Scribe\Attributes;

use Attribute;

#[Attribute(Attribute::TARGET_FUNCTION | Attribute::TARGET_METHOD | Attribute::TARGET_CLASS)]
class Endpoint
{
    public function __construct(
        public string  $title,
        public ?string $description = '',
        /** You can use the separate #[Authenticated] attribute, or pass authenticated: false to this. */
        public ?bool   $authenticated = null,
    )
    {
    }

    public function toArray()
    {
        $data = [
            "title" => $this->title,
            "description" => $this->description,
        ];
        if (!is_null($this->authenticated)) {
            $data["authenticated"] = $this->authenticated;
        }

        return $data;
    }
}