| @@ 7-26 (lines=20) @@ | ||
| 4 | ||
| 5 | use AlgoWeb\ODataMetadata\xsdRestrictions; |
|
| 6 | ||
| 7 | trait TFunctionImportParameterAndReturnTypeTrait |
|
| 8 | { |
|
| 9 | use EDMSimpleTypeTrait, TQualifiedNameTrait, xsdRestrictions; |
|
| 10 | ||
| 11 | public function isTFunctionImportParameterAndReturnTypeValid($string) |
|
| 12 | { |
|
| 13 | $regex = "Collection\([^ \t]{1,}(\.[^ \t]{1,}){0,}\)"; |
|
| 14 | ||
| 15 | if (!is_string($string)) { |
|
| 16 | throw new \InvalidArgumentException("Input must be a string"); |
|
| 17 | } |
|
| 18 | if ($this->isEDMSimpleTypeValid($string)) { |
|
| 19 | return true; |
|
| 20 | } |
|
| 21 | if ($this->isTQualifiedNameValid($string)) { |
|
| 22 | return true; |
|
| 23 | } |
|
| 24 | return $this->matchesRegexPattern($regex, $string); |
|
| 25 | } |
|
| 26 | } |
|
| 27 | ||
| @@ 7-28 (lines=22) @@ | ||
| 4 | ||
| 5 | use AlgoWeb\ODataMetadata\xsdRestrictions; |
|
| 6 | ||
| 7 | trait TPropertyTypeTrait |
|
| 8 | { |
|
| 9 | use EDMSimpleTypeTrait, TQualifiedNameTrait, xsdRestrictions; |
|
| 10 | ||
| 11 | public function isTPropertyTypeValid($string) |
|
| 12 | { |
|
| 13 | //The below pattern represents the allowed identifiers in ECMA specification |
|
| 14 | // plus the '.' for namespace qualification |
|
| 15 | $regex = "[\p{L}\p{Nl}][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,}(\.[\p{L}\p{Nl}][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,}){0,}"; |
|
| 16 | ||
| 17 | if (!is_string($string)) { |
|
| 18 | throw new \InvalidArgumentException("Input must be a string"); |
|
| 19 | } |
|
| 20 | if ($this->isEDMSimpleTypeValid($string)) { |
|
| 21 | return true; |
|
| 22 | } |
|
| 23 | if ($this->isTQualifiedNameValid($string)) { |
|
| 24 | return true; |
|
| 25 | } |
|
| 26 | return $this->matchesRegexPattern($regex, $string); |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||