| @@ 45-58 (lines=14) @@ | ||
| 42 | * @param mixed $value |
|
| 43 | * @return mixed |
|
| 44 | */ |
|
| 45 | public function toResource(Attribute $definition, $value) |
|
| 46 | { |
|
| 47 | if (! $definition->hasType()) { |
|
| 48 | return $this->processNotTypedToResource($definition, $value); |
|
| 49 | } |
|
| 50 | ||
| 51 | $type = $definition->getType(); |
|
| 52 | ||
| 53 | if (isset($this->handlers[$type])) { |
|
| 54 | return $this->processHandlerToResource($definition, $value); |
|
| 55 | } |
|
| 56 | ||
| 57 | throw new UnknownDataTypeException($definition); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Process data-type |
|
| @@ 67-80 (lines=14) @@ | ||
| 64 | * @param mixed $value |
|
| 65 | * @return mixed |
|
| 66 | */ |
|
| 67 | public function fromResource(Attribute $definition, $value) |
|
| 68 | { |
|
| 69 | if (! $definition->hasType()) { |
|
| 70 | return $this->processNotTypedFromResource($definition, $value); |
|
| 71 | } |
|
| 72 | ||
| 73 | $type = $definition->getType(); |
|
| 74 | ||
| 75 | if (isset($this->handlers[$type])) { |
|
| 76 | return $this->processHandlerFromResource($definition, $value); |
|
| 77 | } |
|
| 78 | ||
| 79 | throw new UnknownDataTypeException($definition); |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Process not-typed value |
|