| @@ 206-226 (lines=21) @@ | ||
| 203 | * @param string $definition |
|
| 204 | * @param Attribute $attribute |
|
| 205 | */ |
|
| 206 | protected function processDataType(string $definition, Attribute $attribute) |
|
| 207 | { |
|
| 208 | if (! preg_match(self::DATATYPE_PATTERN, $definition, $matches)) { |
|
| 209 | throw new \LogicException(sprintf('Data-type definition "%s" is invalid.', $definition)); |
|
| 210 | } |
|
| 211 | ||
| 212 | $attribute->setType($matches['type']); |
|
| 213 | ||
| 214 | if (! empty($matches['many'])) { |
|
| 215 | $attribute->setMany(); |
|
| 216 | } |
|
| 217 | ||
| 218 | if (empty($matches['params'])) { |
|
| 219 | return; |
|
| 220 | } |
|
| 221 | ||
| 222 | $parameters = explode(',', $matches['params']); |
|
| 223 | $parameters = array_map('trim', $parameters); |
|
| 224 | ||
| 225 | $attribute->setTypeParameters($parameters); |
|
| 226 | } |
|
| 227 | } |
|
| @@ 95-115 (lines=21) @@ | ||
| 92 | * @param string $definition |
|
| 93 | * @param Attribute $attribute |
|
| 94 | */ |
|
| 95 | protected function processDataType(string $definition, Attribute $attribute) |
|
| 96 | { |
|
| 97 | if (! preg_match(self::DATATYPE_PATTERN, $definition, $matches)) { |
|
| 98 | throw new \LogicException(sprintf('Data-type definition "%s" is invalid.', $definition)); |
|
| 99 | } |
|
| 100 | ||
| 101 | $attribute->setType($matches['type']); |
|
| 102 | ||
| 103 | if (! empty($matches['many'])) { |
|
| 104 | $attribute->setMany(); |
|
| 105 | } |
|
| 106 | ||
| 107 | if (empty($matches['params'])) { |
|
| 108 | return; |
|
| 109 | } |
|
| 110 | ||
| 111 | $parameters = explode(',', $matches['params']); |
|
| 112 | $parameters = array_map('trim', $parameters); |
|
| 113 | ||
| 114 | $attribute->setTypeParameters($parameters); |
|
| 115 | } |
|
| 116 | } |
|