Skip to content

Commit

Permalink
Access environment variable accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Dec 9, 2023
1 parent aaafb1f commit c454739
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/php/websocket/Environment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,31 @@ public function arguments() { return $this->arguments; }

/** @return web.Logging */
public function logging() { return $this->logging; }

/**
* Returns a given environment variable
*
* @param string $name
* @return ?string
*/
public function variable($name) {
return false === ($env= getenv($name)) ? null : $env;
}

/**
* Pass a given environment variable and value. Pass NULL in value to
* remove this environment variable.
*
* @param string $name
* @param ?string $value
* @return self
*/
public function export($name, $value) {
if (null === $value) {
putenv($name);
} else {
putenv($name.'='.$value);
}
return $this;
}
}

0 comments on commit c454739

Please sign in to comment.