[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 3 // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue 4 // SPDX-License-Identifier: BSD-3-Clause 5 6 declare(strict_types=1); 7 8 namespace SimplePie\HTTP; 9 10 /** 11 * HTTP Response for rax text 12 * 13 * This interface must be interoperable with Psr\Http\Message\ResponseInterface 14 * @see https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface 15 * 16 * @internal 17 */ 18 final class RawTextResponse implements Response 19 { 20 /** 21 * @var string 22 */ 23 private $raw_text; 24 25 /** 26 * @var string 27 */ 28 private $permanent_url; 29 30 /** 31 * @var array<non-empty-array<string>> 32 */ 33 private $headers = []; 34 35 /** 36 * @var string 37 */ 38 private $requested_url; 39 40 public function __construct(string $raw_text, string $filepath) 41 { 42 $this->raw_text = $raw_text; 43 $this->permanent_url = $filepath; 44 $this->requested_url = $filepath; 45 } 46 47 public function get_permanent_uri(): string 48 { 49 return $this->permanent_url; 50 } 51 52 public function get_final_requested_uri(): string 53 { 54 return $this->requested_url; 55 } 56 57 public function get_status_code(): int 58 { 59 return 200; 60 } 61 62 public function get_headers(): array 63 { 64 return $this->headers; 65 } 66 67 public function has_header(string $name): bool 68 { 69 return isset($this->headers[strtolower($name)]); 70 } 71 72 public function get_header(string $name): array 73 { 74 return isset($this->headers[strtolower($name)]) ? $this->headers[$name] : []; 75 } 76 77 public function with_header(string $name, $value) 78 { 79 $new = clone $this; 80 81 $newHeader = [ 82 strtolower($name) => (array) $value, 83 ]; 84 $new->headers = $newHeader + $this->headers; 85 86 return $new; 87 } 88 89 public function get_header_line(string $name): string 90 { 91 return isset($this->headers[strtolower($name)]) ? implode(", ", $this->headers[$name]) : ''; 92 } 93 94 public function get_body_content(): string 95 { 96 return $this->raw_text; 97 } 98 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Wed Sep 17 08:20:04 2025 | Cross-referenced by PHPXref |