expected, $keys); if($missing){ throw new \RuntimeException('missing expected callback keys: ' . implode(', ', $missing)); } $this->data = $data; } public function getData() { return $this->data; } public static function fromEnv($source = self::ENV_ALL) { switch(strtolower($source)){ case 'post': $data = $_POST; break; case 'get': $data = $_GET; break; case 'all': $data = array_merge($_GET, $_POST); break; default: throw new \InvalidArgumentException('invalid source: ' . $source); } return new static($data); } }