12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- declare(strict_types=1);
- namespace Hyperf\Utils;
- class Resource
- {
-
- public static function from(string $body, string $filename = 'php://temp')
- {
- $resource = fopen($filename, 'r+');
- if ($body !== '') {
- fwrite($resource, $body);
- fseek($resource, 0);
- }
- return $resource;
- }
- public static function fromMemory(string $body)
- {
- return static::from($body, 'php://memory');
- }
- }
|