|
@@ 125-140 (lines=16) @@
|
| 122 |
|
* @param mixed $value |
| 123 |
|
* @return mixed |
| 124 |
|
*/ |
| 125 |
|
protected function processTypeToResource(Attribute $definition, $value) |
| 126 |
|
{ |
| 127 |
|
$type = $definition->getType(); |
| 128 |
|
|
| 129 |
|
if (isset($this->registeredTypes[$type])) { |
| 130 |
|
$parameters = $definition->getTypeParameters(); |
| 131 |
|
|
| 132 |
|
return $this->registeredTypes[$type]->toResource($value, $parameters); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
if (in_array($type, $this->genericTypes)) { |
| 136 |
|
return $this->processGenericType($type, $value); |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
throw new \LogicException(sprintf('Unable to handle unknown type "%s" of attribute "%s"', $type, $definition->getName())); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
/** |
| 143 |
|
* Process data-type |
|
@@ 149-164 (lines=16) @@
|
| 146 |
|
* @param mixed $value |
| 147 |
|
* @return mixed |
| 148 |
|
*/ |
| 149 |
|
protected function processResourceToType(Attribute $definition, $value) |
| 150 |
|
{ |
| 151 |
|
$type = $definition->getType(); |
| 152 |
|
|
| 153 |
|
if (isset($this->registeredTypes[$type])) { |
| 154 |
|
$parameters = $definition->getTypeParameters(); |
| 155 |
|
|
| 156 |
|
return $this->registeredTypes[$type]->fromResource($value, $parameters); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
if (in_array($type, $this->genericTypes)) { |
| 160 |
|
return $this->processGenericType($type, $value); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
throw new \LogicException(sprintf('Unable to handle unknown type "%s" of attribute "%s"', $type, $definition->getName())); |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
/** |
| 167 |
|
* Process generic data-types |