Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ListCommand | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| run | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 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 React\Socket\ConnectionInterface; |
| 8 | |
| 9 | class ListCommand implements CommandInterface |
| 10 | { |
| 11 | public function run(ApieContext $apieContext, string $arg = ''): ApieContext |
| 12 | { |
| 13 | $conn = $apieContext->getContext(ConnectionInterface::class); |
| 14 | $currentFolder = $apieContext->getContext(FtpConstants::CURRENT_FOLDER); |
| 15 | assert($currentFolder instanceof VirtualFolderInterface); |
| 16 | $conn->write("150 Here comes the directory listing\r\n"); |
| 17 | foreach ($currentFolder->getChildren() as $child) { |
| 18 | $conn->write("-rw-r--r-- 1 user group 0 Jan 1 00:00 " . $child->getName() . "\r\n"); |
| 19 | } |
| 20 | $conn->write("226 Directory send OK\r\n"); |
| 21 | return $apieContext; |
| 22 | } |
| 23 | } |