HumHub Documentation (unofficial)

NumberComparator extends Comparator
in package

NumberComparator compiles a simple comparison to an anonymous subroutine, which you can call with a value to be tested again.

Now this would be very pointless, if NumberCompare didn't understand magnitudes.

The target value may use magnitudes of kilobytes (k, ki), megabytes (m, mi), or gigabytes (g, gi). Those suffixed with an i use the appropriate 2**n version in accordance with the IEC standard: http://physics.nist.gov/cuu/Units/binary.html

Based on the Perl Number::Compare module.

Tags
author

Fabien Potencier fabien@symfony.com PHP port

author

Richard Clamp richardc@unixbeard.net Perl version

copyright

2004-2005 Fabien Potencier fabien@symfony.com

copyright

2002 Richard Clamp richardc@unixbeard.net

see
http://physics.nist.gov/cuu/Units/binary.html

Table of Contents

Properties

$operator  : mixed
$target  : mixed

Methods

__construct()  : mixed
getOperator()  : string
Gets the comparison operator.
getTarget()  : string
Gets the target value.
setOperator()  : mixed
Sets the comparison operator.
setTarget()  : mixed
test()  : bool
Tests against the target.
doSetOperator()  : void

Properties

Methods

__construct()

public __construct(string|null $test) : mixed
Parameters
$test : string|null

A comparison string or null

Tags
throws
InvalidArgumentException

If the test is not understood

getOperator()

Gets the comparison operator.

public getOperator() : string
Return values
string

getTarget()

Gets the target value.

public getTarget() : string
Return values
string

setOperator()

Sets the comparison operator.

public setOperator(string $operator) : mixed
Parameters
$operator : string
Tags
throws
InvalidArgumentException
deprecated

set the operator via the constructor instead

setTarget()

public setTarget(string $target) : mixed
Parameters
$target : string
Tags
deprecated

set the target via the constructor instead

test()

Tests against the target.

public test(mixed $test) : bool
Parameters
$test : mixed

A test value

Return values
bool

doSetOperator()

private doSetOperator(string $operator) : void
Parameters
$operator : string

        
On this page

Search results