| 1 |
<?php |
| 2 |
|
| 3 |
namespace Shellbox\Command; |
| 4 |
|
| 5 |
use Psr\Http\Message\UriInterface; |
| 6 |
|
| 7 |
/** |
| 8 |
* @since 4.1.0 |
| 9 |
*/ |
| 10 |
class InputFileFromUrl extends InputFile { |
| 11 |
/** |
| 12 |
* @var UriInterface|string |
| 13 |
*/ |
| 14 |
private $url; |
| 15 |
|
| 16 |
/** |
| 17 |
* @var array |
| 18 |
*/ |
| 19 |
private $headers = []; |
| 20 |
|
| 21 |
/** |
| 22 |
* @internal |
| 23 |
* @param UriInterface|string $url |
| 24 |
*/ |
| 25 |
public function __construct( $url ) { |
| 26 |
$this->url = $url; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Replace the current array of headers with the specified list. The array |
| 31 |
* should be in Guzzle's format: an associative array where the key is the |
| 32 |
* header name and the value is either a string or an array of strings. |
| 33 |
* Array values are used to send multiple headers with the same name. |
| 34 |
* |
| 35 |
* @param array $headers |
| 36 |
* @return $this |
| 37 |
*/ |
| 38 |
public function headers( array $headers ) { |
| 39 |
$this->headers = $headers; |
| 40 |
return $this; |
| 41 |
} |
| 42 |
|
| 43 |
public function getClientData() { |
| 44 |
return [ |
| 45 |
'type' => 'url', |
| 46 |
'url' => (string)$this->url, |
| 47 |
'headers' => $this->headers |
| 48 |
]; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* @return UriInterface|string |
| 53 |
*/ |
| 54 |
public function getUrl() { |
| 55 |
return $this->url; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* @return array |
| 60 |
*/ |
| 61 |
public function getHeaders() { |
| 62 |
return $this->headers; |
| 63 |
} |
| 64 |
} |