Documentation

Password extends Varchar
in package

A Password with validation and hashing functionality

Tags
author

norb

Table of Contents

Properties

$value  : mixed

Methods

__construct()  : mixed
The constructor takes the unhhashed password and stores it hashed
__toString()  : string
Make sure to overwrite this method in the implementations
defaultValidators()  : array<string|int, mixed>
Overwrite this message if a DataType needs validation methods that are always applied
equals()  : mixed
Compares the String value
hash()  : bool|Error
Takes the clearttext password and returnes the hashed string
ifExists()  : callable
in()  : mixed
Stores the $value as string casting it
isDecimal()  : callable
Returns a test testing if a string is a decimal number.
length()  : callable
matchRegEx()  : callable
Retuns a test tesing if its input matches a regular expression.
maxLength()  : callable
minLength()  : callable
notBlank()  : callable
NotBlank
notNull()  : callable
NotNull
oneOf()  : callable
out()  : mixed
Returns the $value applying the output filters
required()  : callable
unique()  : callable
not implemented - remove?
validate()  : mixed
value()  : mixed
Returns the internal value

Properties

$value

protected mixed $value

The internal value of the DataType

Methods

__construct()

The constructor takes the unhhashed password and stores it hashed

public __construct([string $password = null ]) : mixed

You have to manually execute the validatio method before you pass the cleartext password to the constructor!

The DomainObjects call the constructor with no argument and call the in() method manually, not hashing the password. This is important if it is loaded from the database.

Parameters
$password : string = null

__toString()

Make sure to overwrite this method in the implementations

public __toString() : string
Return values
string

The string representation of the DataType

defaultValidators()

Overwrite this message if a DataType needs validation methods that are always applied

public static defaultValidators() : array<string|int, mixed>
Return values
array<string|int, mixed>

equals()

Compares the String value

public equals(mixed $compare) : mixed
Parameters
$compare : mixed

The value to be compared

hash()

Takes the clearttext password and returnes the hashed string

public hash(string $password) : bool|Error
Parameters
$password : string

The cleartext password to be hashed

Tags
todo

Replace all usages of password hashing with this method, and update to phps password_hash() function

Return values
bool|Error

True if validatiion passed Error with the errors

ifExists()

public static ifExists(callable $test) : callable
Parameters
$test : callable
Return values
callable

Returns a predicate that tests a value using $test if it exists.

in()

Stores the $value as string casting it

public in(mixed $value) : mixed
Parameters
$value : mixed

isDecimal()

Returns a test testing if a string is a decimal number.

public static isDecimal() : callable
Return values
callable

length()

public static length(int $n) : callable
Parameters
$n : int
Return values
callable

Returns a predicate that tests if its argument is of length $n.

matchRegEx()

Retuns a test tesing if its input matches a regular expression.

public static matchRegEx(string $regex[, string $translationId = 'INVALID_VALUE' ]) : callable
Parameters
$regex : string

The regex to check against. PCRE Regex Syntax

$translationId : string = 'INVALID_VALUE'

The translation id for the Error message from translations/errors_[DE|FR].xml

Return values
callable

maxLength()

public static maxLength(int $n) : callable
Parameters
$n : int
Return values
callable

Returns a predicate that tests if its argument is of length $n or less.

minLength()

public static minLength(int $n) : callable
Parameters
$n : int
Return values
callable

Returns a predicate that tests if its argument is of length $n or greater.

notBlank()

NotBlank

public static notBlank() : callable
Return values
callable

notNull()

NotNull

public static notNull() : callable
Return values
callable

oneOf()

public static oneOf(mixed $lst) : callable
Parameters
$lst : mixed
Return values
callable

Returns a predicate that test if it's argument is one of several elements.

out()

Returns the $value applying the output filters

public out() : mixed

This method should be overwritten in the concrete implementation

Tags
todo

Filters are yet to be implemented!

required()

public static required() : callable
Return values
callable

Returns a predicate that tests for the existence of it's argument.

unique()

not implemented - remove?

public static unique() : callable
Return values
callable

Returns a predicate that tests if it's argument is unique in it's environment.

validate()

public static validate(string $password) : mixed
Parameters
$password : string

value()

Returns the internal value

public value() : mixed

        
On this page

Search results