Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ListCommand
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 run
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2namespace Apie\FtpServer\Commands;
3
4use Apie\ApieFileSystem\Virtual\VirtualFolderInterface;
5use Apie\Core\Context\ApieContext;
6use Apie\FtpServer\FtpConstants;
7use React\Socket\ConnectionInterface;
8
9class 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}