/** * @param \sndsgd\http\Route ...$routes */ public function __construct(Route ...$routes) { if (count($routes) < 1) { throw new \BadMethodCallException("failed to create empty instance of " . __CLASS__); } parent::__construct($routes, true); }
/** * @param array<string,mixed> $values * @param string $emulateNodeType The environment to emulate * @throws \LogicException If the actual and emulated node types match */ public function __construct(array $values = [], string $emulateNodeType = "") { # allow array access, but force read only parent::__construct($values, true); # set the node type using the system environment variable # if the envvar is missing, just default to a dev environment $nodeType = $values[self::SYSTEM_ENVVAR_NAME] ?? self::DEV; $this->nodeType = $this->validateNodeType($nodeType); # if the node type should be emulated, we'll set it as another property # this gives us the ability to load the real node type's config (with # service connection details), but to execute conditional blocks for the # emulated node type if ($emulateNodeType !== "") { if ($emulateNodeType === $this->nodeType) { throw new \LogicException("invalid value provided for 'emulateNodeType'; " . "emulating the actual node type is not permitted"); } $this->emulatedNodeType = $this->validateNodeType($emulateNodeType); } }