-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionValue.php
More file actions
90 lines (78 loc) · 1.51 KB
/
Copy pathOptionValue.php
File metadata and controls
90 lines (78 loc) · 1.51 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace App\Object;
use App\Service\StringNormalizer;
use JsonSerializable;
class OptionValue implements JsonSerializable
{
private $code;
private $name;
private $value;
public function __construct($code, $name, $value)
{
$this->setCode($code);
$this->setName($name);
$this->setValue($value);
}
/**
* @return mixed
*/
public function getCode()
{
return StringNormalizer::toSnake($this->code . '_' . $this->getValue());
}
/**
* @param mixed $code
*/
public function setCode($code): void
{
$this->code = $code;
}
/**
* @return mixed
*/
public function getName()
{
return StringNormalizer::toTitle($this->name);
}
/**
* @param mixed $name
*/
public function setName($name): void
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getValue()
{
return $this->value;
}
/**
* @param mixed $value
*/
public function setValue($value): void
{
$this->value = $value;
}
/**
* Specify data which should be serialized to JSON
*
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4
*/
public function jsonSerialize()
{
return get_object_vars($this);
}
public function toObject()
{
return [
'code' => $this->getCode(),
'name' => $this->getName(),
'value' => $this->getValue(),
];
}
}