<?php
    include_once "Reflection.php";
    class RequestHeader {
        use ReflectionHook;
        static $_attributes = [];
        static $readyHeaders = false;
        public function __construct()
        {
            if(!RequestHeader::$readyHeaders)
            {
                foreach ($_SERVER as $name => $value) 
                { 
                    if (substr($name, 0, 5) == 'HTTP_') 
                    { 
                        RequestHeader::$_attributes[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; 
                    } 
                }
            };
        }
        public static function get($name)
        {
            return (new static)->{$name};
        }
        public static function set($name, $value)
        {
            $requestHeader = new static;
            $requestHeader->{$name} = $value;
        }
        public function setAttribute($name, $value)
        {
            $formarly = ucfirst(strtolower($name));
            header("$formarly: $value");
        }
        public function getAttribute($name)
        {
            $formarly = ucfirst(strtolower($name));
            return RequestHeader::$_attributes[$formarly] ?? null;
        }
    };