-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Add KeymanSiteEnvironment #12
base: main
Are you sure you want to change the base?
Changes from 5 commits
f834646
e0a4910
3f1fcce
360ffe4
b3bbaa2
103900c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Keyman\Site\Common; | ||
|
||
class KeymanSiteEnvironment { | ||
|
||
protected static function _Init($class) { | ||
$env = getenv(); | ||
$props = get_class_vars($class); | ||
foreach($props as $name => $value) { | ||
if (isset($env[$name])) { | ||
self::$instance->$name = $env[$name]; | ||
} | ||
} | ||
} | ||
|
||
public static function Debug($class) { | ||
$props = get_class_vars($class); | ||
var_dump($props); | ||
} | ||
|
||
public static function IsSet($name) { | ||
if (isset(self::$instance->$name) && !is_null(self::$instance->$name)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking ahead to refactoring and Will we want additional functions to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'd prefer to rewrite how that particular function works. It's suboptimal at present.
No, if the env var is unsset, then the property value should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I meant for 2. to check when vars are initialized to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is needed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back to draft since this line is giving me errors