-
Notifications
You must be signed in to change notification settings - Fork 0
/
Field.php
76 lines (67 loc) · 1.15 KB
/
Field.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
<?php
namespace shintio\profile;
use yii\helpers\ArrayHelper;
/**
* Class Field
* @package shintio\profile
*/
class Field
{
/**
* @var int
*/
public $id;
/**
* @var string
*/
public $code;
/**
* @var string
*/
public $name;
/**
* @var FieldType
*/
public $type;
/**
* @var mixed
*/
private $value;
/**
* Field constructor.
* @param array $config
*/
public function __construct(array $config=[])
{
$this->id=ArrayHelper::getValue($config,'id',0);
$this->code=ArrayHelper::getValue($config,'code','field');
$this->name=ArrayHelper::getValue($config,'name','field');
$this->value=$config['value'];
if(gettype($config['type'])==='object')
{
$this->type=$config['type'];
}
else
{
if(gettype($config['type'])==='string'||gettype($config['type'])==='array')
{
$this->type=new FieldType($config['type']);
}
}
}
/**
* @return mixed
*/
public function getValue()
{
return $this->value;
}
/**
* @param mixed $value
*/
public function setValue($value)
{
// TODO: validate $value
$this->value=$value;
}
}