Skip to content

Commit 45f6c4d

Browse files
committed
fix: Remove unnecessary exception throwing and improve URI building logic in Euri class
1 parent 7146db2 commit 45f6c4d

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

src/Ease/Euri.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ public static function validate(string $uri): array
121121
* @param object $object Object exposing getMyKey()
122122
* @param array<string, mixed> $args Optional query parameters
123123
*
124-
* @throws \InvalidArgumentException
125-
*
126124
* @return string EaseURI
127125
*/
128126
public static function fromObject(object $object, array $args = []): string
@@ -137,10 +135,6 @@ public static function fromObject(object $object, array $args = []): string
137135
$class = $ref->getShortName();
138136
$id = (string) $object->getMyKey();
139137

140-
if ($id === '') {
141-
throw new \InvalidArgumentException('Object identifier is empty');
142-
}
143-
144138
$path = str_replace('\\', '/', $namespace);
145139
$path = $path ? $path.'/'.$class : $class;
146140

@@ -151,11 +145,11 @@ public static function fromObject(object $object, array $args = []): string
151145
$base .= '?'.http_build_query($args, '', '&', \PHP_QUERY_RFC3986);
152146
}
153147

154-
return $base.'#'.rawurlencode($id);
148+
return $base.(\strlen($id) ? '#'.rawurlencode($id) : '');
155149
}
156150

157151
/**
158-
* Exctract Class part only.
152+
* Extract Class part only.
159153
*
160154
* @return string Class
161155
*/

0 commit comments

Comments
 (0)