Skip to content

Commit

Permalink
Fold foreach loop into chained null-coalesce operators
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Dec 10, 2023
1 parent 284cb72 commit 5338d51
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/php/web/Environment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ public function logging() { return $this->logging; }

/** @return io.Path */
public function tempDir() {
foreach (['TEMP', 'TMP', 'TMPDIR', 'TEMPDIR'] as $variant) {
if (isset($_ENV[$variant])) return new Path($_ENV[$variant]);
}
return new Path(sys_get_temp_dir());
return new Path(
$_ENV['TEMP'] ??
$_ENV['TMP'] ??
$_ENV['TMPDIR'] ??
$_ENV['TEMPDIR'] ??
sys_get_temp_dir()
);
}

/**
Expand Down

0 comments on commit 5338d51

Please sign in to comment.