| Total Complexity | 9 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class PhpDownloader implements DownloaderInterface |
||
| 7 | { |
||
| 8 | /** @var resource */ |
||
| 9 | private $context; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * PhpDownloader constructor. |
||
| 13 | * @param resource|null $context A valid context created with stream_context_create |
||
| 14 | */ |
||
| 15 | 21 | public function __construct($context = null) |
|
| 21 | 21 | } |
|
| 22 | |||
| 23 | /** @return resource */ |
||
| 24 | 12 | public function getContext() |
|
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Set the context (created with stream_context_create) that will be used when try to download |
||
| 31 | * @param resource $context |
||
| 32 | * @see https://php.net/stream-context-create |
||
| 33 | */ |
||
| 34 | 21 | public function setContext($context) |
|
| 35 | { |
||
| 36 | 21 | if (! is_resource($context)) { |
|
| 37 | 1 | throw new \InvalidArgumentException('Provided context is not a resource'); |
|
| 38 | } |
||
| 39 | 21 | $this->context = $context; |
|
| 40 | 21 | } |
|
| 41 | |||
| 42 | /** @return resource */ |
||
| 43 | 20 | public function createContext() |
|
| 46 | } |
||
| 47 | |||
| 48 | 10 | public function downloadTo(string $source, string $destination) |
|
| 57 | } |
||
| 58 | 9 | } |
|
| 60 |