Oihana Php Ftp

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
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Constants

FTP  : string = 'ftp'
The 'ftp' parameter key.

Properties

$ftp  : FtpClient|null
The FTP client reference.

Methods

assertFtp()  : void
Asserts that the 'ftp' client property has been initialized.
initializeFtp()  : static
Initializes the 'ftp' property.

Constants

Properties

Methods

assertFtp()

Asserts that the 'ftp' client property has been initialized.

public assertFtp() : void
Tags
throws
UnexpectedValueException

When the ftp client is not set.

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 ftp entry).

$container : ContainerInterface|null = null

An optional PSR-11 container for service resolution.

Tags
throws
ContainerExceptionInterface

When the container fails to retrieve the entry.

NotFoundExceptionInterface

When no entry is found for the given service name.

Return values
static

This instance, for chaining.

On this page

Search results