Bicycle/System/Classes/HTTP/Header.php
Egor Isaev b516ca07dc Initial commit: Bicycle PHP MVC micro-framework
Core MVC, HTTP client, Session, Cookie, Config, HTTPException — 111 PHPUnit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 10:04:19 +03:00

42 lines
832 B
PHP

<?php
/**
* @package Bicycle
* @author Egor Isaev
* @description HTTP/Header.php
* @copyright (c) 04/06/2026
*/
namespace System\Classes\HTTP;
use ArrayObject;
class Header extends ArrayObject
{
public function __construct(array $input = [])
{
parent::__construct($input);
}
public function __toString(): string
{
$output = '';
foreach ($this as $key => $value) {
$output .= $key . ': ' . (is_array($value) ? implode(', ', $value) : $value) . "\r\n";
}
return $output . "\r\n";
}
public function send(): void
{
if (headers_sent()) {
return;
}
foreach ($this as $key => $value) {
header($key . ': ' . (is_array($value) ? implode(', ', $value) : $value));
}
}
}