Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| RetrCommand | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| run | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | namespace Apie\FtpServer\Commands; |
| 3 | |
| 4 | use Apie\ApieFileSystem\Virtual\VirtualFolderInterface; |
| 5 | use Apie\Core\Context\ApieContext; |
| 6 | use Apie\FtpServer\FtpConstants; |
| 7 | use Apie\Webdav\Dav\ApieDirectory; |
| 8 | use React\Socket\ConnectionInterface; |
| 9 | |
| 10 | class RetrCommand implements CommandInterface |
| 11 | { |
| 12 | public function run(ApieContext $apieContext, string $arg = ''): ApieContext |
| 13 | { |
| 14 | $conn = $apieContext->getContext(ConnectionInterface::class); |
| 15 | if ($arg) { |
| 16 | $conn->write("501 Missing filename\r\n"); |
| 17 | } else { |
| 18 | $folder = $apieContext->getContext(FtpConstants::CURRENT_FOLDER); |
| 19 | assert($folder instanceof VirtualFolderInterface); |
| 20 | $file = $folder->getChild($arg); |
| 21 | if ($file === null) { |
| 22 | $conn->write("550 File not found\r\n"); |
| 23 | } else { |
| 24 | $conn->write("150 Opening data connection\r\n"); |
| 25 | $conn->write($file->getContents()); |
| 26 | $conn->write("\r\n"); |
| 27 | $conn->write("226 Transfer complete\r\n"); |
| 28 | } |
| 29 | } |
| 30 | return $apieContext; |
| 31 | } |
| 32 | } |