예제 #1
0
 /**
  * Constructs an instance of this class.
  *
  * @param string         $string
  * @param MediaType|null $mediaType
  */
 public function __construct(string $string, MediaType $mediaType = null)
 {
     if ($mediaType === null) {
         $mediaType = new MediaType('text/plain; charset=utf-8');
     }
     parent::__construct(new MemoryStream($string), $mediaType);
 }
예제 #2
0
 /**
  * Constructs an instance of this class.
  *
  * @param string         $uri
  * @param MediaType|null $mediaType
  */
 public function __construct(string $uri, MediaType $mediaType = null)
 {
     if ($mediaType === null) {
         $mediaType = MediaType::fromFile($uri, true);
     }
     parent::__construct(new ResourceStream($uri), $mediaType);
 }