Imported into new repository.
This commit is contained in:
commit
ac2255d24d
187 changed files with 15021 additions and 0 deletions
src/Http/Content
36
src/Http/Content/StringContent.php
Normal file
36
src/Http/Content/StringContent.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
// StringContent.php
|
||||
// Created: 2022-02-10
|
||||
// Updated: 2022-02-27
|
||||
|
||||
namespace Index\Http\Content;
|
||||
|
||||
use Stringable;
|
||||
|
||||
class StringContent implements Stringable, IHttpContent {
|
||||
private string $string;
|
||||
|
||||
public function __construct(string $string) {
|
||||
$this->string = $string;
|
||||
}
|
||||
|
||||
public function getString(): string {
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
public function __toString(): string {
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
public static function fromObject(string $string): StringContent {
|
||||
return new StringContent($string);
|
||||
}
|
||||
|
||||
public static function fromFile(string $path): StringContent {
|
||||
return new StringContent(file_get_contents($path));
|
||||
}
|
||||
|
||||
public static function fromRequest(): StringContent {
|
||||
return self::fromFile('php://input');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue