Skip to content

Commit e34d8e1

Browse files
committed
use of null coalescing operator
1 parent 6a36828 commit e34d8e1

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

src/Index/Index.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function getGlobalDefinitions(): \Generator
136136
*/
137137
public function getDefinitionsForNamespace(string $namespace): \Generator
138138
{
139-
foreach ($this->doGetDefinitionsForNamespace($namespace) as $fqn => $definition) {
139+
foreach ($this->namespaceDefinitions[$namespace] ?? [] as $fqn => $definition) {
140140
yield $fqn => $definition;
141141
}
142142
}
@@ -151,7 +151,7 @@ public function getDefinitionsForNamespace(string $namespace): \Generator
151151
public function getDefinition(string $fqn, bool $globalFallback = false)
152152
{
153153
$namespace = $this->extractNamespace($fqn);
154-
$definitions = $this->doGetDefinitionsForNamespace($namespace);
154+
$definitions = $this->namespaceDefinitions[$namespace] ?? [];
155155

156156
if (isset($definitions[$fqn])) {
157157
return $definitions[$fqn];
@@ -213,12 +213,7 @@ public function removeDefinition(string $fqn)
213213
*/
214214
public function getReferenceUris(string $fqn): \Generator
215215
{
216-
$uris = isset($this->references[$fqn])
217-
? $this->references[$fqn]
218-
: []
219-
;
220-
221-
foreach ($uris as $uri) {
216+
foreach ($this->references[$fqn] ?? [] as $uri) {
222217
yield $uri;
223218
}
224219
}
@@ -331,18 +326,4 @@ private function extractNamespace(string $fqn): string
331326

332327
return $fqn;
333328
}
334-
335-
/**
336-
* Returns the Definitions that are in the given namespace
337-
*
338-
* @param string $namespace
339-
* @return Definition[]
340-
*/
341-
private function doGetDefinitionsForNamespace(string $namespace): array
342-
{
343-
return isset($this->namespaceDefinitions[$namespace])
344-
? $this->namespaceDefinitions[$namespace]
345-
: []
346-
;
347-
}
348329
}

0 commit comments

Comments
 (0)