| 1 | <?php |
||
| 7 | class Convention implements Contracts\Convention |
||
| 8 | { |
||
| 9 | 53 | public function getType($property) |
|
| 20 | |||
| 21 | 53 | public function getTarantoolType($type) |
|
| 29 | |||
| 30 | 53 | public function isPrimitive($type) |
|
| 34 | |||
| 35 | 53 | public function encode($type, $value) |
|
| 36 | { |
||
| 37 | 53 | if (!$this->isPrimitive($type)) { |
|
| 38 | 4 | if ($value instanceof Contracts\Entity) { |
|
| 39 | 4 | return $value->getId(); |
|
| 40 | } |
||
| 41 | |||
| 42 | 4 | return +$value; |
|
| 43 | } |
||
| 44 | |||
| 45 | 53 | if ($type == 'integer') { |
|
| 46 | 53 | return +$value; |
|
| 47 | } |
||
| 48 | |||
| 49 | 53 | if (is_null($value)) { |
|
| 50 | return; |
||
| 51 | } |
||
| 52 | |||
| 53 | 53 | if (!is_array($value)) { |
|
| 54 | 53 | return "$value"; |
|
| 55 | } |
||
| 56 | |||
| 57 | 3 | return $value; |
|
| 58 | } |
||
| 59 | |||
| 60 | 53 | public function decode($type, $value) |
|
| 68 | } |
||
| 69 |