@@ 52-69 (lines=18) @@ | ||
49 | * @param mixed $value |
|
50 | * @return mixed |
|
51 | */ |
|
52 | public function toResource(Attribute $definition, $value) |
|
53 | { |
|
54 | if (! $definition->hasType()) { |
|
55 | return $this->processNotTypedToResource($definition, $value); |
|
56 | } |
|
57 | ||
58 | $type = $definition->getType(); |
|
59 | ||
60 | if (isset($this->registeredTypes[$type])) { |
|
61 | return $this->processHandlerToResource($definition, $value); |
|
62 | } |
|
63 | ||
64 | if (in_array($type, self::$genericTypes)) { |
|
65 | return $this->processGeneric($definition, $value); |
|
66 | } |
|
67 | ||
68 | throw new UnknownDataTypeException($definition); |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * Process data-type |
|
@@ 78-95 (lines=18) @@ | ||
75 | * @param mixed $value |
|
76 | * @return mixed |
|
77 | */ |
|
78 | public function fromResource(Attribute $definition, $value) |
|
79 | { |
|
80 | if (! $definition->hasType()) { |
|
81 | return $this->processNotTypedFromResource($definition, $value); |
|
82 | } |
|
83 | ||
84 | $type = $definition->getType(); |
|
85 | ||
86 | if (isset($this->registeredTypes[$type])) { |
|
87 | return $this->processHandlerFromResource($definition, $value); |
|
88 | } |
|
89 | ||
90 | if (in_array($type, self::$genericTypes)) { |
|
91 | return $this->processGeneric($definition, $value, false); |
|
92 | } |
|
93 | ||
94 | throw new UnknownDataTypeException($definition); |
|
95 | } |
|
96 | ||
97 | /** |
|
98 | * Process not-typed value |