Oihana Php Ftp

FtpCredentials implements Stringable

An immutable-by-intent holder for the FTP login credentials.

The password is treated as a secret: it is never rendered by __toString() (only the user name is) and it is wiped by clear() — invoked automatically on destruction. When ext-sodium is available, sodium_memzero() performs a genuine in-place memory wipe (the only reliable one in PHP userland); otherwise the property is simply reset to an empty string.

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Interfaces

Stringable

Properties

$password  : string
The login password.
$username  : string
The login user name.

Methods

__construct()  : mixed
Creates a new credentials holder.
__destruct()  : mixed
Wipes the password when the instance is destroyed.
__toString()  : string
Returns the user name. The password is never exposed this way.
clear()  : void
Wipes the password from memory and resets it to an empty string.
isAnonymous()  : bool
Indicates whether these credentials describe an anonymous login.

Properties

Methods

__construct()

Creates a new credentials holder.

public __construct([string $username = '' ][, string $password = '' ]) : mixed
Parameters
$username : string = ''

The login user name.

$password : string = ''

The login password (kept secret).

__destruct()

Wipes the password when the instance is destroyed.

public __destruct() : mixed
Tags
throws
SodiumException

__toString()

Returns the user name. The password is never exposed this way.

public __toString() : string
Return values
string

The login user name.

clear()

Wipes the password from memory and resets it to an empty string.

public clear() : void

Idempotent: calling it more than once is harmless. When ext-sodium is present, the secret buffer is zeroed in place with sodium_memzero(); otherwise PHP cannot reliably scrub the original buffer, so the property is just reset.

Tags
throws
SodiumException

isAnonymous()

Indicates whether these credentials describe an anonymous login.

public isAnonymous() : bool
Return values
bool

True when the user name is empty or anonymous (case-insensitive).

On this page

Search results