-
Notifications
You must be signed in to change notification settings - Fork 14
/
Configuration.php
77 lines (62 loc) · 1.74 KB
/
Configuration.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace inklabs\kommerce\Entity;
use inklabs\kommerce\Lib\UuidInterface;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
class Configuration implements IdEntityInterface
{
use TimeTrait, IdTrait;
/** @var string */
protected $key;
/** @var string */
protected $name;
/** @var string */
protected $value;
public function __construct(string $key, string $name, string $value, UuidInterface $id = null)
{
$this->setId($id);
$this->setCreated();
$this->key = $key;
$this->name = $name;
$this->value = $value;
}
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('key', new Assert\NotBlank);
$metadata->addPropertyConstraint('key', new Assert\Length([
'max' => 30,
]));
$metadata->addPropertyConstraint('name', new Assert\NotBlank);
$metadata->addPropertyConstraint('name', new Assert\Length([
'max' => 50,
]));
$metadata->addPropertyConstraint('value', new Assert\NotBlank);
$metadata->addPropertyConstraint('value', new Assert\Length([
'max' => 255,
]));
}
public function setKey(string $key)
{
$this->key = $key;
}
public function getKey(): string
{
return $this->key;
}
public function setName(string $name)
{
$this->name = $name;
}
public function getName(): string
{
return $this->name;
}
public function setValue(string $value)
{
$this->value = $value;
}
public function getValue(): string
{
return $this->value;
}
}