FtpConnector::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 16
rs 9.9
cc 2
nc 2
nop 2
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Command Class
6
 * @category    Ticaje
7
 * @package     Ticaje_Dummy
8
 * @author      Hector Luis Barrientos <[email protected]>
9
 */
10
11
namespace Ticaje\Dummy\Console\Command;
12
13
use Symfony\Component\Console\Command\Command;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
use Ticaje\AConnector\Gateway\Client\Ftp as FtpClient;
18
use Ticaje\AConnector\Gateway\Provider\Credentials as CredentialsManager;
19
20
/**
21
 * Class Instantiate
22
 * @package Ticaje\Connector\Command
23
 */
24
class FtpConnector extends Command
25
{
26
    protected $client;
27
28
    protected $credentials;
29
30
    public function __construct(
31
        FtpClient $client,
32
        CredentialsManager $credentials,
33
        string $name = null
34
    ) {
35
        $this->client = $client;
36
        $this->credentials = $credentials;
37
        parent::__construct($name);
38
    }
39
40
    protected function configure()
41
    {
42
        $this->setName("ticaje:test:ftp:connector");
43
        $this->setDescription("Test Connector Extension.");
44
        parent::configure();
45
    }
46
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $credentials = [
50
            'username' => 'sftpuser',
51
            'password' => 'sftpuser',
52
            'host' => 'localhost',
53
            'port' => 22,
54
55
        ];
56
        $result = null;
57
        $this->credentials->set($credentials);
58
        $connected = $this->client->connect($this->credentials);
59
        if ($connected) {
60
            $result = $this->client->download('comeco/sftp/Descriptions.csv');
61
        }
62
        $output->write($result, true);
63
    }
64
}
65