A gateway/firewall task to be able to talk someone about the real job
Fibinger Ádám
2021-10-22 fd7692eae00cbb0db3e6b732f68357e3c64a8a8b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?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;
    }
}