HasFtpClientTrait
Provides a standardized way to hold and initialize an {@see FtpClient} within a class.
Responsibilities:
- storing a reference to an
FtpClient; - asserting that the client has been initialized before use;
- initializing the client from an array of parameters and an optional PSR-11 container.
$this->initializeFtp( [ 'ftp' => 'ftpServiceName' ] , $container ) ;
$this->assertFtp() ;
$this->ftp->connect() ;
Tags
Table of Contents
Constants
- FTP : string = 'ftp'
- The 'ftp' parameter key.
Properties
Methods
- assertFtp() : void
- Asserts that the 'ftp' client property has been initialized.
- initializeFtp() : static
- Initializes the 'ftp' property.
Constants
FTP
The 'ftp' parameter key.
public
string
FTP
= 'ftp'
Properties
$ftp
The FTP client reference.
public
FtpClient|null
$ftp
= null
Methods
assertFtp()
Asserts that the 'ftp' client property has been initialized.
public
assertFtp() : void
Tags
initializeFtp()
Initializes the 'ftp' property.
public
initializeFtp([array<string|int, mixed> $init = [] ][, ContainerInterface|null $container = null ]) : static
Accepts an FtpClient instance directly, or a service name resolved from the
given PSR-11 container.
Parameters
- $init : array<string|int, mixed> = []
-
The initialization parameters (expects an
ftpentry). - $container : ContainerInterface|null = null
-
An optional PSR-11 container for service resolution.
Tags
Return values
static —This instance, for chaining.