<?php
|
|
namespace App\Dto;
|
|
use ApiPlatform\Core\Annotation\ApiProperty;
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
final class CreateSecretDTO
|
{
|
/**
|
* @var string
|
* @ApiProperty(attributes={"openapi_context"={"description" = "This text will be saved as a secret"}})
|
* @Assert\NotNull
|
* @Assert\NotBlank
|
*/
|
public $secret;
|
/**
|
* @var integer
|
* @ApiProperty(attributes={"openapi_context"={"description" = "The secret won't be available after the given number of views. It must be greater than 0."}})
|
* @Assert\NotBlank
|
* @Assert\NotNull
|
* @Assert\Range(
|
* min=1
|
* )
|
*/
|
public $expireAfterViews;
|
|
/**
|
* @var integer
|
* @ApiProperty(attributes={"openapi_context"={"description" = "The secret won't be available after the given time. The value is provided in minutes. 0 means never expires."}})
|
* @Assert\NotBlank
|
* @Assert\NotNull
|
* @Assert\Range(
|
* min = 0
|
* )
|
*/
|
public $expireAfter;
|
|
public static function fromArray($secret = null, $expireAfter = null, $expireAfterViews = null)
|
{
|
$s = new CreateSecretDTO();
|
|
$s->secret = $secret;
|
$s->expireAfter = $expireAfter;
|
$s->expireAfterViews = $expireAfterViews;
|
|
return $s;
|
}
|
}
|