Skip to content

Commit f9eab8f

Browse files
committed
Use null-coalesce assignments
1 parent b342351 commit f9eab8f

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

src/Model/LazyBSONArray.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,7 @@ public function offsetExists($offset): bool
159159

160160
$offset = (int) $offset;
161161

162-
// If we've looked for the value, return the cached result
163-
if (isset($this->exists[$offset])) {
164-
return $this->exists[$offset];
165-
}
166-
167-
return $this->exists[$offset] = $this->bson->has($offset);
162+
return $this->exists[$offset] ??= $this->bson->has($offset);
168163
}
169164

170165
/**

src/Model/LazyBSONDocument.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,7 @@ public function __get(string $property)
127127

128128
public function __isset(string $name): bool
129129
{
130-
// If we've looked for the value, return the cached result
131-
if (isset($this->exists[$name])) {
132-
return $this->exists[$name];
133-
}
134-
135-
return $this->exists[$name] = $this->bson->has($name);
130+
return $this->exists[$name] ??= $this->bson->has($name);
136131
}
137132

138133
/** @param TValue $value */

0 commit comments

Comments
 (0)