1 | <?php |
||
20 | class Field implements FieldInterface |
||
21 | { |
||
22 | protected $table; |
||
23 | protected $name; |
||
24 | protected $type; |
||
25 | protected $mapping; |
||
26 | protected $attributes; |
||
27 | |||
28 | /** |
||
29 | * Constructor |
||
30 | * |
||
31 | * @param string $field |
||
32 | * @param string $type |
||
33 | * @param array $attributes |
||
34 | * @param null|string $mapping |
||
35 | */ |
||
36 | public function __construct($field, $type = 'string', $attributes = [], $mapping = null) |
||
43 | |||
44 | /** |
||
45 | * Prepares attributes, changes them into key value pairs |
||
46 | * |
||
47 | * @param array $attributes |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | protected function prepareAttributes(array $attributes) |
||
68 | |||
69 | /** |
||
70 | * Returns table owning the field |
||
71 | * |
||
72 | * @param null|string $table |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function table($table = null) |
||
84 | |||
85 | /** |
||
86 | * Returns relation name in entity |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | public function name() |
||
94 | |||
95 | /** |
||
96 | * Returns relation type |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | public function type() |
||
104 | |||
105 | /** |
||
106 | * Returns mapped table cell or null when no mapping |
||
107 | * |
||
108 | * @return null|string |
||
109 | */ |
||
110 | public function mapping() |
||
114 | |||
115 | /** |
||
116 | * Returns fields mapped name or if not mapped returns property name |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | public function mappedName() |
||
124 | |||
125 | /** |
||
126 | * Returns attribute value or null if not set |
||
127 | * |
||
128 | * @param string $attribute |
||
129 | * |
||
130 | * @return mixed |
||
131 | */ |
||
132 | public function attribute($attribute) |
||
140 | |||
141 | /** |
||
142 | * Returns array containing field attributes |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | public function attributes() |
||
150 | } |
||
151 |