Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| TypeCommand | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| run | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | namespace Apie\FtpServer\Commands; |
| 3 | |
| 4 | use Apie\Core\Context\ApieContext; |
| 5 | use React\Socket\ConnectionInterface; |
| 6 | |
| 7 | class TypeCommand implements CommandInterface |
| 8 | { |
| 9 | public function run(ApieContext $apieContext, string $arg = ''): ApieContext |
| 10 | { |
| 11 | $conn = $apieContext->getContext(ConnectionInterface::class); |
| 12 | $type = strtoupper(trim($arg)); |
| 13 | if ($type === 'A') { |
| 14 | $conn->write("200 Type set to A (ASCII)\r\n"); |
| 15 | return $apieContext->withContext('ftp_type', 'A'); |
| 16 | } elseif ($type === 'I') { |
| 17 | $conn->write("200 Type set to I (Binary)\r\n"); |
| 18 | return $apieContext->withContext('ftp_type', 'I'); |
| 19 | } else { |
| 20 | $conn->write("504 Command not implemented for that parameter\r\n"); |
| 21 | return $apieContext; |
| 22 | } |
| 23 | } |
| 24 | } |